Flow Designer: How to check if the Return Date is updated while Wait for 24 hours before Return Date

bbf35621
Kilo Sage

I am new to Flow Designer and I couldn't figure out how to add to check if the Return Date field has been updated by the user and it is today to bypass it while I have a Wait Condition to wait for 24 Hours before the Return Date to send a notification. Right now, it is able to wait for 24 hours before Return Date before proceeding to the next step. How can I add if the user updated Return Date by returning early by today to bypass the Wait condition to send a notification? Here is a screenshot example of my Flow,

bbf35621_0-1686578611446.png

 

4 REPLIES 4

OlaN
Giga Sage
Giga Sage

Hi,

I believe you could use the "Wait for condition" action in this scenario.

Instead of using the "Wait for a duration of time" which is found under Flow logic, use "Wait for condition" which is found under Action > ServiceNow Core

 

With it you wait for a specific action to take place, for example a field is updated, and you can also enable a timeout, so it will not wait indefinitely.

flow-wait-for-condition.png

Hi,

Thank you for the reply! What condition should I pick for Return Date is updated/changed because I do not see that in the option? I do see Enable timeout checkbox, but where can I set it up for 24 hours before the Return Date if the user didn't update anything on the Return Date?

Riya Verma
Kilo Sage
Kilo Sage

Hi @bbf35621 ,

 

Hope you are doing great.

to check if the Return Date field has been updated by the user and if it is today, in order to bypass the Wait Condition and send a notification, modify the flow:

  1. find out the point in flow where you want to check if it is updated and its today.
  2. Add a decision step and in decision step use below code to determine if the Return Date has been updated and is today

 

 

var returnDate = current.variables.return_date; 
var currentDate = gs.nowDateTime(); /

// Check if Return Date has been updated and is today
if (returnDate != '' && returnDate.date() == currentDate.date()) {
    // Return Date has been updated by the user and is today--> Bypass the Wait Condition and proceed to send the notification
    gs.addInfoMessage('Return Date has been updated today. Skipping the Wait Condition.');
    // Connect the decision step to the notification step in the Flow designer
} 
else {
    // Return Date has not been updated or it is not today, based on  existing Wait Condition in your Flow
}

 

 

  •  Save the changes made to the Flow and test the updated behavior
Please mark the appropriate response as correct answer and helpful, This may help other community users to follow correct solution.
Regards,
Riya Verma

Hi Riya,

Thank you for the help! What is the name of the decision step in flow designer? I only see a step called "Make a decision". I do not see any script box to fill out code and instead, it is required to create a Decision table. Do I need to create a decision table?