- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2024 08:46 AM
Hello all,
I am have a requirement to set the state of the RITM to a certain value when the state on an SCTASK changes, but only if none of the other SCTASKs on the RITM are in an on hold state. I have tried various things in my business rule, but can't seem to wrap my head around the logic enough to make it work correctly. If anyone can assist it would be appreciated.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2024 09:23 AM - edited 02-02-2024 09:24 AM
Hello @TEdwards ,
Create a business rule on sc_task table. as below and add condtion as "state changes".
(function executeRule(current, previous /*null when async*/) {
// Query the sc_task table for tasks related to the current RITM and are not on hold
var task = new GlideRecord('sc_task');
task.addQuery('request_item', current.request_item);
task.addQuery('state','-5'); // check the value of on hold choice value
task.query();
// If no other tasks are on hold, set the RITM state to 'Work in Progress'
if (!task.next()) {
var ritm = new GlideRecord('sc_req_item');
if (ritm.get(current.request_item)) {
ritm.state = '1'; // update to state value that you want as per your business requirement
ritm.update();
}
}else{
// Do something if required
}
})(current, previous);
Kindly mark the answer ✔️Correct or Helpful ✔️If it addresses your concern.
Regards,
Siddhesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2024 09:23 AM - edited 02-02-2024 09:24 AM
Hello @TEdwards ,
Create a business rule on sc_task table. as below and add condtion as "state changes".
(function executeRule(current, previous /*null when async*/) {
// Query the sc_task table for tasks related to the current RITM and are not on hold
var task = new GlideRecord('sc_task');
task.addQuery('request_item', current.request_item);
task.addQuery('state','-5'); // check the value of on hold choice value
task.query();
// If no other tasks are on hold, set the RITM state to 'Work in Progress'
if (!task.next()) {
var ritm = new GlideRecord('sc_req_item');
if (ritm.get(current.request_item)) {
ritm.state = '1'; // update to state value that you want as per your business requirement
ritm.update();
}
}else{
// Do something if required
}
})(current, previous);
Kindly mark the answer ✔️Correct or Helpful ✔️If it addresses your concern.
Regards,
Siddhesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2024 10:24 AM
Thank you so much for your help, Siddhesh. I have been going in circles for a while on this, and your solution was perfect.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2024 10:25 AM
@TEdwards Glad to help 😊