Mapping watchlist from RITM to parent REQ record
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-11-2024 08:53 AM
We have a requirement to map the watchlist from a RITM record to its parent REQ record. What is the best way to do this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-11-2024 01:08 PM
You could use either a business rule or a flow to handle the copy of the field to the request, you just have to make sure if there are multiple RITMs under a REQ, that you join the new watchlist members instead of replacing. Also consider doing some cleansing on duplicated users.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-12-2024 01:49 AM
Hi @jaredscharf ,
You can use the Business rule script to copy the watchlist from an RITM record to the corresponding REQ record:
1) Create a Business Rule on the sc_req_item table (RITM table).
2) Set it to run "After Insert" or "After Update" depending on when you want the watchlist to be copied.
3) Use the following script in the Script section:
if (current.watch_list) {
// Retrieve the parent request (REQ) record
var req = new GlideRecord('sc_request');
if (req.get(current.request)) {
// Copy the Watchlist from RITM to REQ
req.watch_list = current.watch_list;
req.update(); // Save changes to the REQ record
}
}
Thanks
Vivek
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-12-2024 06:44 AM
Hi @jaredscharf
- Create a Business Rule on the sc_req_item table.
- Set the Trigger:
- When: Before or After Insert/Update
- Condition: Check if the watch_list field is updated.
- Script:
// Business Rule on 'sc_req_item' table
(function executeRule(current, previous /*null when async*/) {
if (current.watch_list != previous.watch_list) {
var req = new GlideRecord('sc_request');
if (req.get(current.request)) {
req.watch_list = current.watch_list; // Update watchlist on the parent request
req.update();
}
}
})(current, previous);
Please appreciate the efforts of community contributors by marking the appropriate response as the correct answer and helpful. This may help other community users to follow the correct solution in the future.
********************************************************************************************************
Cheers,
Prashant Kumar
ServiceNow Technical Architect
Community Profile LinkedIn YouTube Medium TopMate
********************************************************************************************************