- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-23-2023 10:48 PM
For one RITM, we built two sc_tasks. When I try to close one sc_task, RITM closes but another sc_task remains open. Can somebody assist me in closing all sc_tasks before RITM closes?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-23-2023 11:04 PM
you can use after update BR on sc_task with proper conditions for State value
Condition: State [IS ONE OF] Closed complete, Closed incomplete, Closed skipped
Script:
(function executeRule(current, previous /*null when async*/) {
// Add your code here
// check if there is no active task for this RITM
var gr = new GlideRecord("sc_task");
gr.addActiveQuery();
gr.addQuery("request_item", current.request_item);
gr.setLimit(1);
gr.query();
if (!gr.hasNext()) {
var ritm = current.request_item.getRefRecord();
ritm.state = 3;
ritm.update();
}
})(current, previous);
OR
you can also use Flow designer with no script for this
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
‎04-24-2023 12:54 AM
please use script I shared above.
sharing again with some changes
(function executeRule(current, previous /*null when async*/) {
// Add your code here
// check if there is no active task for this RITM
var gr = new GlideRecord("sc_task");
gr.addActiveQuery();
gr.addQuery("request_item", current.request_item);
gr.setLimit(1);
gr.query();
if (!gr.hasNext()) {
var ritm = current.request_item.getRefRecord();
ritm.state = current.state;
ritm.update();
}
})(current, previous);
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
‎04-24-2023 01:05 AM
Hi @Ankur Bawiskar ,
its not working when i close one task its automatically closing RITM, another task is in open state.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-24-2023 01:49 AM
share your BR configuration screenshot and latest script
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-24-2023 02:31 AM
i did a mistake script is working thank you.