Query changes before next CAB meeting

jeffrey_sharpe
Tera Contributor

I have a requirement to perform an action on changes if certain criteria is not met on changes. Whats needed is to check today at 9:00 if changes that will be implemented today are not ready for CAB to automatically reschedule them. I have that part figured out. However, included in that needs to be changes that are planned to be installed tomorrow prior to 9:00 need to be rescheduled as well. 

2 ACCEPTED SOLUTIONS

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @jeffrey_sharpe 

 

Try to add one more condition

AGLearnNGrow_0-1736867669556.png

 

*************************************************************************************************************
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]

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

View solution in original post

You may need to put 'hour','10','LE' in double-quotes instead of single quotes

View solution in original post

10 REPLIES 10

jcmings
Mega Sage

How are you doing this now? Flow designer? You could achieve your ask with flow designer through the Look up records flow action (using your criteria) and a For each loop (passing in the Look up records data pill... e.g. for each record in the look up records search). Inside the for each loop, you'd do something like Update record and you can update the date.

Currently just running a scheduled job to query changes when the meetings starts and as I mentioned it takes care of the changes for "Today" but cant capture "Tomorrow's" changes before 9.

Gotcha. Can you share the script you're using? Are you open to trying a flow?

I am open to trying a flow, however I have no experience using Flow Designer
 
var changegr = new GlideRecord('change_request');
changegr.addEncodedQuery('start_dateONToday@javascript:gs.beginningOfToday()@javascript:gs.endOfToday()^type=normal^state=-5^ORstate=-4^active=true^u_authority_approval=CAB^ORu_authority_approval=VP');
changegr.query();
while (changegr.next()) {
var count = changegr.getRowCount();
gs.info('Changenumber is ' + changegr.number);
rescheduleChange();
}
function rescheduleChange() {
new WorkflowApprovalUtils().cancelAll(changegr,"Change request is being rescheduled");
new Workflow().restartWorkflow(changegr);
new OpConflictUtils().clearConflicts(changegr.getUniqueValue());
changegr.approval="not requested";
new OP_ChangeUtil().closeAWSReq(changegr.getUniqueValue(), 2);
changegr.setValue('u_exception',false);
changegr.setValue('conflict_status','Not Run');
changegr.setValue('u_choice_2','');
changegr.setValue('start_date','');
changegr.setValue('end_date','');
changegr.setValue('conflict_last_run','');
changegr.setValue('cab_recommendation','');
changegr.setValue('u_conflict_accepted', false);
changegr.setValue('cab_date', '');
changegr.setWorkflow(false);
changegr.setValue("state", -5);
changegr.work_notes = "Change did not have the required approvals in place prior to the CAB meeting. Change has been rescheduled via automation. Please set a new Planned Window, adjust your change as needed, and re-submit for approvals.";
changegr.update();
}
gs.log('Total number of changes ' + count);