The CreatorCon Call for Content is officially open! Get started here.

How to fetch all the tasks under a request and check whether there are any rejected task in it

Sowbarnika S1
Tera Contributor

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

1 ACCEPTED SOLUTION

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

View solution in original post

7 REPLIES 7

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

Hi @Sowbarnika S1,



Thanks and Regards,

Saurabh Gupta

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @Sowbarnika S1 

 

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]

****************************************************************************************************************