How to set RITM to Closed Skipped and Request to Closed Rejected when Approval is rejected
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-14-2023 12:26 PM
All,
I have a requirement to set the RITM to Closed Skipped and Request to Closed Rejected when the Approval is rejected.
Pasting a screenshot for reference.
Any help will be appreciated!
Thanks,
Mallika
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-14-2023 06:20 PM
Hi @mallikabhupathi ,
1)You can add a set value to update RITM to "Closed Skipped"
2)Add run script to update Request to "Closed Rejection" as below
Another approach :or if you can write a BR/Flow to update these if you don't to do it in the workflow.
Acc
Accept the solution if this helps.
Thank you,
Hemanth
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-15-2023 11:35 AM
Hi @Hemanth M ,
I tried your way but the state is reflecting Closed Complete on both the RITM and Request.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-14-2023 09:28 PM
HI @mallikabhupathi ,
I trust you are doing great.
- Open the workflow for the approval process in ServiceNow.
- Identify the activity or step in the workflow where the approval rejection occurs. Let's assume it's called "Approval Rejection Activity."
- In the "Approval Rejection Activity," add a new script action to perform the necessary updates on the RITM and Request records. Below is an example of the code you can use:
// Get the current RITM record
var ritm = new GlideRecord('sc_req_item');
ritm.addQuery('sys_id', current.request_item.sys_id);
ritm.query();
if (ritm.next()) {
// Set RITM state to Closed Skipped
ritm.setValue('state', 8); // 8 represents the "Closed Skipped" state in ServiceNow
// Update the RITM record
ritm.update();
}
// Get the current Request record
var request = new GlideRecord('sc_request');
request.addQuery('sys_id', current.request_item.request.sys_id);
request.query();
if (request.next()) {
// Set Request state to Closed Rejected
request.setValue('state', 7); // 7 represents the "Closed Rejected" state in ServiceNow
// Update the Request record
request.update();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-15-2023 11:34 AM
Hi @Amit Gujarathi ,
I tried using this script but the RITM and Request states are showing Closed Complete.
I also tried to replace the 'sys_id' with the actual sys id of the catalog item and it is not reflecting the state.