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

Saurabh Gupta
Kilo Patron
Kilo Patron

Hi,
When you want to check if there is any rejected task previously?

 

 


Thanks and Regards,

Saurabh Gupta

Hi @Saurabh Gupta  

 

When a new task is created under a request.... I need to check if there are any previously rejected task under that particular request and have to trigger an event if there are any.

Hi
This can be done.
Can you please tell me the state of the task when it got rejected.

 

 


Thanks and Regards,

Saurabh Gupta

Hi @Saurabh Gupta  

 

when this task gets rejected the state will be changed to 'closed skipped'.

 

Could you please guide me on how to achieve this through business rule