- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2022 08:53 PM
After raised request from catalog item, state in req page showing open(ticked in snapshot)
Now my requirement is: After approved RITM, state in Req page should show "work in progress"(tiked in snapshot for reference)
Please suggest how to achive solution for this.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2022 09:02 PM - edited 11-22-2022 09:03 PM
when your RITM is approved does your state on RITM changes or does the approval status on RITM changes to approved? (because some trigger on RITM is required). If yes you can write after update BR on request item with below code:
condition : approval changes to approved.
var req = new GlideRecord('sc_request');
req.addQuery('sys_id',current.request);
req.query();
if(req.next())
{
req.state = 2;
req.update();
}
Raghav
MVP 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2022 10:58 PM - edited 11-22-2022 11:33 PM
Hi @Ramakrishna6 ,
Add run script activity after approval is approved activity and write down below code in that:-
var gr = new GlideRecord("sc_request");
gr.addQuery('sys_id',current.request);
gr.query();
if (gr.next()) {
gr.autoSysFields(false);
gr.setWorkflow(false);
gr.state = '2' ; //Work in progress backend value
gr.update();
}
Please Mark My Response as Correct/Helpful based on Impact
Regards,
Gunjan Kiratkar
2X ServiceNow MVP
Community Rising Star 2022
Youtube : ServiceNow Guy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2022 09:02 PM - edited 11-22-2022 09:03 PM
when your RITM is approved does your state on RITM changes or does the approval status on RITM changes to approved? (because some trigger on RITM is required). If yes you can write after update BR on request item with below code:
condition : approval changes to approved.
var req = new GlideRecord('sc_request');
req.addQuery('sys_id',current.request);
req.query();
if(req.next())
{
req.state = 2;
req.update();
}
Raghav
MVP 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2022 10:02 PM
Hi Ragav,
Thanks for your quick reply,
Mentioned BR working fine.
But in my current organization most catalog items RITM workflow dosen't have (Approval action- Approved) activity. That's why state is showing "Requested" only after approved RITM also(Ticked in snapshot)
Could you please suggest solution: (when state is showing "requested" after approved RITM) Req state should be "work in progress".
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2022 10:25 PM
Some trigger has to be there on RITM to make this work. If your catalog item has workflow then change the approval to approved or state to RITM to wip after approval using wotkflow.
Once this is done, run the BR according to RITM state change or approval change.
Please mark the answer correct/helpful accordingly.
Raghav
MVP 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2022 11:27 PM
On your RITM workflow after approval activity you can add the same script in "run script" activity which you added in the BR:
var req = new GlideRecord('sc_request');
req.addQuery('sys_id',current.request);
req.query();
if(req.next())
{
req.state = 2;
req.update();
}
Raghav
MVP 2023