Date time not captured on every append line activity

Hi Team,

I am using this code System.DateTime.Now.ToString(“dd/MM/yyyy hh:mm:ss”) to capture the date time in every append file activity I use. If i use the whole code without saving in any variable it works fine but if i saved the code in string variable called systemTime of string data type then it captures the date time at the very beginning of the process and the same time captures for every append line activity.

For eg.

Robot process started 11:43:09
Robot logged in 11:43: 09
Robot Clicked on the case number 11:43: 09

If I use the code directly in every append line activity then it captures correctly in the following format

Robot process started 11:43:09
Robot logged in 11:43: 15
Robot Clicked on the case number 11:43: 50

Please clarify

Thanks,
Ula

Can you please share your workflow or share the screenshot of the logic written for above scenario?
What is the output you are getting when you are saving the value in a string variable?

Because you are saving time in variable and passing it to remaining flow. That’s why it is giving same time.

Hi Please find the screen shots

image

Like this I am using append line activity to save the log file in notepad but only the starting time captured in every append line activity

Thanks,
Ula

Try below once:
image

Yeah… Its behaving as per the code… If you store a datetime value in variable at start, it will store the a single value (DateTime for that moment)… And it become constant value for whole flow, that’s why its writing same value every time… if you need dynamic value (value where time will be as per the activity execution), then you must initialize it every time or use complete function.

Hi @Boopathi

You are using systemTime Variable which is supposed is global and not initialilse every time you write the log try to make it local or some use Now.ToString("dd-MMM-yyyy HH:mm:ss) instead of variable.

Cheers

Hi All,

Got it. Not sure why failed to understand and will it get initialized everytime if we save the code using datetime variable instead of string.

Thanks,
Ula