- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2024 09:37 PM
I currently set the following business rules.
var taskGr = new GlideAggregate('sc_task');
taskGr.addAggregate('COUNT');
taskGr.addQuery('request_item', current.getUniqueValue());
taskGr.addActiveQuery();
taskGr.query();
taskGr.next();
if (taskGr.getAggregate('COUNT') > 0) {
current.setAbortAction(true);
gs.addErrorMessage("[状況]を更新できません。画面をリフレッシュすると元の値に戻ります。SCTASKを全てクローズすると[状況]は自動で更新されます。");
}
For this script, I'd like to add a restriction that RITM's [State] cannot be changed to [Open] or [Work in Progress] when all SCTASK's [Status] are [Closed(Complete, Incomplete, Skipped)], and a rule that automatically updates RITM's [State] to [Work in Progress] if even one SCTASK's [State] is not [Closed(Complete, Incomplete, Skipped)]
I would like to know a good solution for coding to add the above settings without changing the original script content.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2024 02:44 AM
Hi @Yugo Sakuma,
You may try the following Fix script to achieve the requirement.
1.when any of task is in open/in progress then state field remain as decided in flow once all taks done then RITMs state changes to closed complete.
please refer the following script for better understanding.
var gr = new GlideRecord('sc_req_item');
gr.addEncodedQuery('stateIN-5,1,2');
gr.query();
while(gr.next())
{
var cnt = 0;
var gr_task = new GlideRecord('sc_task');
gr_task.addQuery('request_item',gr.sys_id);
gr_task.query();
while(gr_task.next())
{
if(gr_task.state == '-5' || gr_task.state == '1' || gr_task.state == '2' )
{
cnt++;
break;
}
}
if(cnt == 0)
{
gr.state = '3'; // once all the task state is complete/incomplete/skipped then here set the state as per requirement '3' is referring to closed complete.
gr.update();
}
}
2.For Read only You may use the UI policy. Attaching screenshot for reference.
Please mark my response as correct and helpful if it helped solved your question.
Thanks,
Rohit Suryawanshi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2024 05:35 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2024 10:23 PM
Hi @Yugo Sakuma ,
Have you tried the given solution ?
Let me know if you have any questions.
Please mark my response as correct and helpful if it helped solved your question.
Thanks,
Rohit Suryawanshi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2024 11:16 PM
Hello @Jitendra Diwak1
Thank you for your reply
We have already set up a specific flow for the catalog items associated with this RITM and SCTASK.
This business rule is intended to control when a State is manually changed while the flow “Wait for Condition” is waiting for 14 days.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2024 11:35 PM
Hi @Yugo Sakuma,
Is there any assistance is required or we can close this thread.
Please accept my solution if it works for you and thumps up
Thanks
Jitendra