How do I populate the RITM Assignment Group from SC Task where Multiple Tasks are triggered?

WazzaJC
Tera Expert

How do I populate the RITM Assignment Group from SC Task where Multiple Tasks are triggered?

 

Hi ServiceNow Community Colleagues,

 

My client has a requirement, that the RITM Assignment Group is always populated, upon closure, with the Assignment Group from the SC Task.

 

The challenge we have here, is some RITM's have multiple SC Tasks triggered, with different Assignment Groups.

 

There is a Business Rule in place currently (please see the script below), but this seems to only work for RITM's where a single SC Task is triggered from the RITM.

 

How can I amend this Business Rule Script, to ensure is populates for when all the SC Tasks are triggered, perhaps for example, set the RITM Assignment Group to be the same as the SC Task Assignment Group, for the final Task that is fulfilled, before the RITM is set to closed complete state?

 

So we would make this script always set the RITM Assignment Group, to the same SC Task Assignment Group, that belongs to the last SC Task that is fulfilled, before the RITM goes to closed complete.

 

The client basically, doesn't want blank Assignment Groups on RITM's, for items where multiple SC Tasks are triggered & fulfilled.

 

Many thanks as always for any help or guidance on how to achieve this.

 

Here is the current Business Rule Script (below and screenshot attached) - I need to make this work for the multiple SC Tasks scenario.

 

 

(function executeRule(current, previous /*null when async*/) {

	var grTask = new GlideRecord('sc_task');
	grTask.addQuery('request_item',current.sys_id);
	grTask.query();
	if(grTask.next())
	{
		//gs.addInfoMessage('Number of Tasks:'+grTask.getRowCount());
		if(grTask.getRowCount() == 1)
		{
			//gs.addInfoMessage('Assignment group:'+grTask.assignment_group);
			current.assignment_group = grTask.assignment_group;			
		}
	}

})(current, previous);

 

 

 

Kind Regards.

1 ACCEPTED SOLUTION

SunilKumar_P
Giga Sage

Hi @WazzaJC, If your business rule is on sc_req_item table and with the conditions 'Before Update' and 'State Changes to Closed Complete', you can try the below script.

(function executeRule(current, previous /*null when async*/) {

	var grTask = new GlideRecord('sc_task');
	grTask.addQuery('request_item',current.sys_id);
	grTask.orderByDesc('sys_created_on');
	grTask.setLimit(1);
	grTask.query();
	if(grTask.next())
	{
			current.assignment_group = grTask.assignment_group;			
	}

})(current, previous);

 

Regards,
Sunil

View solution in original post

6 REPLIES 6

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @WazzaJC 

 

There will be always issue when more than 1 task is there. and it is not a good practice to update RITM group based on SC Task. 

 

I know its client requirement but we need to see what value it will bring.

*************************************************************************************************************
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]

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

Thanks @Dr Atul G- LNG  Yes I understand that, however the Client wants this configuration delivered even based on that same advice.

SunilKumar_P
Giga Sage

Hi @WazzaJC, If your business rule is on sc_req_item table and with the conditions 'Before Update' and 'State Changes to Closed Complete', you can try the below script.

(function executeRule(current, previous /*null when async*/) {

	var grTask = new GlideRecord('sc_task');
	grTask.addQuery('request_item',current.sys_id);
	grTask.orderByDesc('sys_created_on');
	grTask.setLimit(1);
	grTask.query();
	if(grTask.next())
	{
			current.assignment_group = grTask.assignment_group;			
	}

})(current, previous);

 

Regards,
Sunil

Hi @SunilKumar_P . Sunil this is excellent ! Thank you very much kind Sir. I really appreciate you took the time to help me with this. I have configured this now on my client's instance and it functions perfectly! Very much appreciated Sunil. Have a great week. šŸ™‚