- 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-23-2022 12:01 AM
You can create an After Update BR on Approval table and make it work only for RITMs.
When the state of the approval changes to Approved, you can query the assoicated Request of the RITM and change the state accordingly. Should work fine.
Regards,
Rana
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2022 10:15 PM
Hi @Ramakrishna6 ,
If you are using the workflow then handle this situation using workflow activity to set the value after approval approved.
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 10:39 PM
Could you please explain clearly, I want Req state field should be "work in progress" But we add activity in RITM workflow that is not reflected to Req page right
in which workflow(Req or RITM) i need to add "set values" activity and where exactly i need to add activity in workflow.
- 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-23-2022 06:35 PM
Hi Gunjan,
Your run script code working fine.
Now state field in Req page showing "work in progress".
Generally (Approval is approved) we can achive using "Approval action" (or) "Set Values" activity in workflow
Could you please suggest how to achive this activity(Approval is approved) through Run script.
I need to achive both (Approval is approved) function and Req state (work in progress) function through runscript only.