Flow Designer Variables - Individually Created Variables for Current Date/Time Returns Same Value

Damian Mudge
Tera Expert

I am creating a Customer Chase Flow which ultimately I want to run as a scheduled job every hour. I have broken this down into just getting the flow to work trigger on an individual ticket before as an end to end process before I loom to expand.

 

The issue I am encountering is throughout the flow (which could take 96hours to complete), I am trying to get the current time and then populate a "Last Chase Sent" date and time field with the current time at that point in the Workflow. I initially thought that each flow variable script would be executed when when it reached that point in the flow, but it appears to return the system time when the workflow was first triggered.

 

Is there a way to configure flow variables to get the system time when it is being called by the process.

 

The Workflow Logic is as follows:

1. Workflow Initiated when Ticket is placed "On hold" with the Hold reason of "Awaiting Customer" and Sets a "Chase Count" to 0.

 

2. The Workflow waits 24hours then Looks up trigger record and if state is still "On hold" and "On hold Reason" is "Awaiting Customer" and if so updates the Trigger Record. The update:

  • adds and entry to the Customer comments; PASS
  • updates a Chase Count variable by 1 to 1; PASS
  • using a Flow Variable to get date and time updates a Date and Time field with the System Time. FAIL

3. The Workflow waits another 24hours then Looks up trigger record and if state is still "On hold" and "On hold Reason" is "Awaiting Customer" Chase Count is 1 updates the Trigger Record. The update:

  • adds and entry to the Customer comments; PASS
  • updates a Chase Count variable by 1 to 2; PASS
  • using another Flow Variable to get date and time updates a Date and Time field with the output of this Flow Variable. FAIL

4. The Workflow waits another 24hours then Looks up trigger record and if state is still "On hold" and "On hold Reason" is "Awaiting Customer" Chase Count is 2 updates the Trigger Record. The update:

  • adds and entry to the Customer comments; PASS
  • updates a Chase Count variable by 1 to 3; PASS
  • using 4th Flow Variable to get the current date and time updates a Date and Time field with the output of the 4th Flow Variable. FAIL

5. Workflow waits 24hours then Looks up trigger record and if state is still "On hold" and "On hold Reason" is "Awaiting Customer" Chase Count is 3 updates the Trigger Record. The update:

  • adds and entry to the Customer comments; PASS
  • sets the state to Resolved; PASS
  • Populates the mandatory fields for Resolving; PASS
  • Clears all the fields used in the Chase Function (Inc, Chase Count, Date Last Chase Sent etc. PASS

FAIL: Where the update fails, it appears to be populating the "Last Chase Sent" date and time field with the system time when the Flow was initiated.

 

I though by defining separate flow variables for each update the value returned would be the system date and time when the actions was performed. 

1 ACCEPTED SOLUTION

Damian Mudge
Tera Expert

@Sanjay191 

Thank you for your guidance. I did not realise that I could set flow variables at different points in a 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. 

View solution in original post

4 REPLIES 4

Damian Mudge
Tera Expert

@Sanjay191 

Thank you for your guidance. I did not realise that I could set flow variables at different points in a 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. 

Ravi Peddineni
Kilo Sage

@Damian Mudge 

 

Is it possible to provide a screenshot of your flow and flow variables?

Hi Ravindranath,

 

It was my lack of knowledge. I am teaching myself some basics in ServiceNow and did not realise that flow variables could be defined later in the flow. By default it put the first flow variable as one of the first steps. As a result I defined all the flow variables in that default location, as a result, all of the entries throughout the rest of the flow returned the same system time. After the comment from @Sanjay191, the penny dropped so to speak and I added flow variables throughout the flow.

 

Here is a screenshot of the updated flow which now seems to be working as I envisaged. Originally, each chase action was a separate workflow with the output of the previous workflow triggering the subsequent workflow. Which works nicely, but I was sure I could create a single workflow, and this is the result. 

 

DamianMudge_0-1726642449596.png

 

Great  @Damian Mudge keep going.