- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-11-2018 12:13 AM
Hi,
I'm fairly new to SNOW development and I'm looking to set the active flag on a change request to false when the change state is set to cancelled as these are currently staying active.
Please advise on the best way to go about this.
Regards,
Paul
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-11-2018 12:23 AM
Hello,
You need to write a one time scheduled job to fix it.
var gr = new GlideRecord('change_request');
gr.addEncodedQuery('state=4^active=true'); //Replace with your cancelled state query.
gr.query();
while(gr.next()){
gr.active = false;
gr.update();
}
You could also write a before update business rule with condition as State changes to cancelled and Set value for Active to False. This will ensure that all new records are synchronized.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-11-2018 12:23 AM
Hello,
You need to write a one time scheduled job to fix it.
var gr = new GlideRecord('change_request');
gr.addEncodedQuery('state=4^active=true'); //Replace with your cancelled state query.
gr.query();
while(gr.next()){
gr.active = false;
gr.update();
}
You could also write a before update business rule with condition as State changes to cancelled and Set value for Active to False. This will ensure that all new records are synchronized.
Thanks