- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2023 10:59 PM
I need to fetch all the tasks under a request and check if we have any rejected tasks under it. If we have any rejected task previously then an event should be triggered. How can I achieve this through business rule
Can anyone please help
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2023 11:50 PM
Hi @Sowbarnika S1
You can write a onAfter insert BR on you task table with following logic.
(function executeRule(current, previous /*null when async*/) {
var task=new GlideRecord(current.getTableName())
task.addQuery('parent',current.parent);
task.addQuery('sys_id','!=',current.getUniqueValue());
task.addQuery('state','7');//Please check in your insatnce the value for closed skipped
task.query();
if(task.next())
{
gs.eventQueue();//Trigger the event
}
})(current, previous);
Thanks and Regards,
Saurabh Gupta
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2023 11:50 PM
Hi @Sowbarnika S1
You can write a onAfter insert BR on you task table with following logic.
(function executeRule(current, previous /*null when async*/) {
var task=new GlideRecord(current.getTableName())
task.addQuery('parent',current.parent);
task.addQuery('sys_id','!=',current.getUniqueValue());
task.addQuery('state','7');//Please check in your insatnce the value for closed skipped
task.query();
if(task.next())
{
gs.eventQueue();//Trigger the event
}
})(current, previous);
Thanks and Regards,
Saurabh Gupta
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2023 12:58 AM
Hi @Sowbarnika S1,
Thanks and Regards,
Saurabh Gupta
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2023 01:28 AM
Not sure why you want to do this via BR. Try to explore the power of Flow Designer which is Low Code / No code and solve many issue quickly.
You can do via Record Look up
and then do for each record.
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]
****************************************************************************************************************