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
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?
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.
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.