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-09-2018 09:47 PM
Can;t you set these values through the workflow?
Here you are writing a after update BR on the Request item table and updating the same table record. This might call itself again and again if condition matches.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2018 04:04 AM
Hi Mrigank,
Thanks for the above.
To give a bit of background to what I am trying to achieve as there is more than likely a better way to achieve this.
We have a catalog item called BAU Change Request. This is for customers to fill in via the customer portal.
The workflow runs through a number of tasks before it gets to a tasks for 'costing'.
On this tasks the user fills in some details and then emails the client and places the task in a pending state waiting a response from the client.
When we hear back from the client it will be one of 3 options:
- Costs accepted
-costs Rejected
-re scope requested
Depending on the response should decide the remaining flow of the workflow.
I have 3 UI actions on the catalog 1 for each response option.
The user selects the required option and this sets a value in the 'u_job_category' field on the sc_task table.
I'm not sure how a value set on the catalog task can be used to then decide the remaining flow of the workflow, so if you could show me the best way to achieve this it will be greatly appreciated.
Thanks
Sam
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2018 04:32 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2018 05:04 AM
Hi Harish,
Is there a better way within the workflow that I can get the answer from a catalog task to decide the route to be taken in the rest of the workflow?
Thanks
Sam
Once try to change your business rule to before instead of after.