To automate state change from Scheduled to Implement

Arun33
Tera Expert

Hi,

 

I want a change request to move automatically from Scheduled to Implement state, at the planned start date/time.

 

I have created a Flow to change from Scheduled to Implement state, at the planned start date/time. but in flow

Wait For Condition if not working:

Arun33_0-1665770355770.png

 

Arun33_2-1665770422994.png

Arun33_4-1665770444040.png

In Wait For Condition I have used script in condition.

 

var start_date = fd_data.trigger.current.start_date;
var on_hold = fd_data.trigger.current.on_hold;
if (start_date == gs.nowDateTime() && on_hold == 'false') {
return true;
}
But this if condition is not working as expected. This if condition should be executed when planned start date/time is equal to system date/time 
 
can anyone help me on this

 

 

 

1 ACCEPTED SOLUTION

Mike_R
Kilo Patron
Kilo Patron

Try using the wait for duration of time Flow Logic

 

Mike_R_0-1665771386608.png

 

View solution in original post

14 REPLIES 14

SVPV
Tera Contributor

Hi Arun

 

Wanted to understand if this works fine as per your requirement?

 

Regards

SVPV

Galfordus1
Tera Contributor

Did anyone figured out what would be the easiest way to handle the flow if start_date  / end_date changes during flow exection?
I know we could do few things, but for a simple thing like that, it seems like a little overkill to cancel the flow itself and retrigger. It would be easier to have most of the logic in one flow.

Changing the dates during change implementation is not as per process or best practice. 

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

I understand and I agree to some extent.

But in special circumstances it might be useful. And besides, this seems like a feature that I would like to know how to best implement in case I need it for any other field change during flow execution, so for sake of knowledge would like to know how to best approach this. 

ChaitrashreeHM
Tera Contributor

Hello Everyone,

 

We can achieve this using Scheduled job run periodically

Use the below script.

var grChange = new GlideRecord('change_request');
grChange.addEncodedQuery('state=-2');
grChange.addQuery('start_date', '<=', new GlideDateTime());
grChange.query();
while (grChange.next()) {
    grChange.state = -1; // Change state to Implement
    grChange.update();
}
 
This works fine and state changes on proper planned start date.
 
Thank you.
 
Please mark this response as correct or helpful if it assisted you with your question.