- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-23-2025 09:29 PM
Good morning.
On a Catalog Form, I have a Workflow. The requirement is on RITM, whenever the person closes the REQTASK, the same person should be added the Approver on RITM.
How can we do this? Through User Approval - Run script? (Screenshot below). Instead of Group approval, I want the same person who closes the REQTASK to be the approver on RITM, so that, once he approves, the next stages in Workflow proceed.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-23-2025 10:02 PM
you can use user approval activity and use script
answer = [];
var req = new GlideRecord('sc_task');
req.orderByDesc('sys_created_on');
req.addQuery('active', 'false');
req.addQuery('request_item', current.sys_id);
req.setLimit(1);
req.query();
if (req.next()) {
answer.push(req.closed_by.toString());
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-24-2025 05:45 AM
Using a Business Rule
Create a Business Rule on the sc_task table (which includes REQTASK):
Name: Add Approver on RITM when REQTASK is closed
Table: Task (sc_task)
Advanced: Checked
When to run: After
Conditions:
state changes to Closed
sys_class_name is sc_req_item (to ensure it's a REQTASK)
Script:
javascriptCopy(function executeRule(current, previous /*null when async*/) { // Get the RITM (Requested Item) record var ritm = new GlideRecord('sc_req_item'); if (ritm.get(current.request_item)) { // Add the user who closed the REQTASK as an approver on the RITM var approval = new GlideRecord('sysapproval_approver'); approval.initialize(); approval.setValue('sysapproval', ritm.sys_id); // Link to RITM approval.setValue('approver', current.closed_by); // User who closed the REQTASK approval.setValue('state', 'requested'); // Set approval state approval.insert(); } })(current, previous);
Activate the Business Rule:
Ensure the Business Rule is active and runs in the appropriate scope