Flow Designer - Flow Variable for Date and Time

Damian Mudge
Tera Expert

Hi All.

 

I am looking for assistance with defining a flow variable a date and timestamp in a new Chase Function I am desiging using Flow Designer.

 

I have defined the flow and it triggers as expected, waits a specific duration as expected, looks up the trigger record to check it still meets the criteria to update the trigger record as expected and then it updates a number if fields on the trigger record. 

 

The issue I am having is getting a date and timestamp added to the trigger record which I want to populate a new "last chase sent" date and time field with the current time in local time.

 

 

The following flow variable returns the date and time in UTC:

 

Script:

var gdt = new GlideDateTime();
return gdt.getValue();
 
Output:
2024-09-12 14:47:48 which is UTC.
 
The following flow variable returns the time in with the local time but with the Month and Day reversed which is seen as 3 months from now:

 

Script:

var gdt = new GlideDateTime();
return gdt2 = new GlideDateTime(gdt.getDisplayValue());
 
Output:
09-12-2024 15:47:48
 
DamianMudge_1-1726217348933.png

 

What do I need to do so that the output is follows which will populate a "Last Chase Sent" date field in the desired format:
 
Desired Outputs:
12-09-2024 15:47:48
2024-09-12 15:47:48
 
This new "Date last sent" field will be updated by the actions of the flow with the date and time the last flow action was completed and will be used later in the process to see if this value is 24hrs or more before the a new flow variable capturing the current date and time NOW.
 
Any guidance would be much appreciated.
1 ACCEPTED SOLUTION

Hello @Damian Mudge  

If you set the flow variable at the time of triggered it will same in whole flow where it used but if you want to change the flow variable value  then you can change it  also as per your need  by set the value in flow designer of that particular variable 

Please Mark Helpful 
Thank you

View solution in original post

9 REPLIES 9

Damian Mudge
Tera Expert

@Sanjay191 / @Community Alums 

 

By hook or by crook I managed to get the desired output by configuring the flow variable with the following script:

 

var gdt1 = new GlideDateTime(); //Always UTC +0
return gdt1.getDisplayValueInternal();
 
This returned the value 2024-09-17 08:13:40 when UTC was 2024-09-17 07:13:40hrs.
 
It has led to another issue which I will post a new question.
 
Thank you both for your suggestions and guidance. 

Hello @Damian Mudge 

GlideDateTime API always gives the time according to you instance timezone not your system timezone so please check that also for same.

Sanjay, Thank you, We are UK based and our instances are hosted in the UK and Ireland so I think it is returning the correct information. But I am drafting another Questions regarding flow variables. I was using the same script throughout the flow, however, I think that the Flow Variables are defined when the Flow is first triggered which is my next issue,

Hello @Damian Mudge  

If you set the flow variable at the time of triggered it will same in whole flow where it used but if you want to change the flow variable value  then you can change it  also as per your need  by set the value in flow designer of that particular variable 

Please Mark Helpful 
Thank you

@Sanjay191 

Thank you. Until you called this out, I did not realise I could set flow variables at different points in the flow. I always thought they were defined at the very top of the flow. I have set flow variables at different stages and it works.