Business rule not setting sc_req_item stage value
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-09-2018 01:49 PM
Hi All,
I am in the middle of creating a new workflow for a catalog item.
I have a business rule running on change of a field on the catalog task. The filed on the catalog task is 'u_job_category'.
When the value of this is 'Rescope requested' the following rule runs:
After update business rule to run when cat item is BAU Change Request V2 and job category changes to 'rescope requested.
(function executeRule(current, previous /*null when async*/) {
var item = current.request_item;
//gs.log("reqItem - " + item);
var gr = new GlideRecord("sc_req_item");
gr.addQuery('sys_id', current.request_item);
gr.query();
if(gr.next()) {
gr.state = 2;
gr.comments = 'test comment';
gr.stage = 'rescope';
gr.u_rescope_requested = 'true';
gr.update();
}
})(current, previous);
The state, comments, and u_rescope_requested fields all work, but I was trying to also set the 'stage' value, but this is not working - due to this I know that the business rule is firing.
I've already added the stage (label = Rescope Requested, value = rescope') to the workflow properties.
I have 2 other business rules that run when job category change to other values and these are setting the stage correctly. I have copied the script from these and pasted it for this business rule and just amended the value to be set, but it still does not set the value.
Any suggestions?
Thanks
Sam
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2018 05:21 AM
Hi Chuck,
I've just been having a further think on this. Is this likely to be linked to how the choice list for the stage field gets created? i.e. the default options, followed by the workflow specific options. So as I am trying to update the field without having the form open I only have access to the default options?
Hope this makes sense?
If so is there a way around this?
Thanks
Sam

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-30-2022 01:11 PM
Marked helpful. Thank you so much! (FWIW I saw Chuck's comment that before is not appropriate for the given use case, but in my situation, it was perfectly suited, and is what I needed to affect a current sc_req_item record's Stage via BR. It only took me ~2 hours of focused searching and reading to find it. Bless you!)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2019 02:08 AM
Write gr.setWorkflow(false); after if(gr.next()) this is working fine for me.
Thanks and Regards,
Nirisha Reddy Kangari