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

Community Alums
Not applicable

Hello @Damian Mudge ,

 

Please try this 

 

var gdt = new GlideDateTime(); var date = new GlideDateTime().getLocalDate(); // Get the local date
var time = new GlideDateTime().getLocalTime(); // Get the local time
var formattedDate = date + ' ' + time;
return formattedDate;
 
Please check the local time of the instance.

Sanjay191
Tera Sage

Hello @Damian Mudge 

I just wanted need more clearity on above senerio, you just wanted to change the  date formate that you get before in flow designer right ?

HI Sanjay, 

 

Thanks for the quick reply.

 

I am trying to get a script that can be used in multiple flow variables that can be compared to the system time / time now that are used in each step of a new Chase Function. The Chase Function is 4 step process as follows:

 

Step 1 First Chase: Workflow is triggered when a Ticket is placed "On hold". (A Business Rules set a "Chase Count" field to "0",  24hours later, a timer wakes up the workflow, looks up the record to get the latest information. If the Ticket is still "On hold" and the "Chase Count" is still "0", then the workflow action updates the Chase Count to "1" and populates the "Last Chase Sent" with the time now.

 

Step 2 Second Chase: 24hours later, the workflow wakes up, looks up the record to get the latest information. If the Ticket is still "On hold" and the "Chase Count" is still "1", then the workflow action updates the Chase Count to "2" and populates the "Last Chase Sent" with the time now.

 

Step 3 Third Chase: 24hours later, the workflow wakes up, looks up the record to get the latest information. If the Ticket is still "On hold" and the "Chase Count" is still "2", then the workflow action updates the Chase Count to "3" and populates the "Last Chase Sent" with the time now.

 

Step 4 Resolves Ticket: 24hours later, the workflow wakes up, looks up the record to get the latest information. If the Ticket is still "On hold" and the "Chase Count" is still "3", then the workflow action resolves the Ticket adding values for Mandatory fields and clears the Last Chase Sent, Chase Count.

 

Kind regards,


Damian

Sanjay191
Tera Sage

if you want the date in the desired date then you can use this below code snippet for the help and elsewise you can use the regex also to formate the date in your desired formate

var date= new GlideDate();//replace new GlideDate() with the incoming date
var date2 = date.getByFormat('yyyy/MM/dd');//now use the date2 to set the field value