Create Recipient List from Business Application Owners

Bryant9
Tera Contributor

I am trying to create a recipient list from Business Application owners, both IT and business. I can pull one or the other, as seen in the screenshots, with the dynamic fields and filtering. However, this creates two lists, one for business owners and one for IT Owners. I need logic/script that pulls both owners into a single list. I am using SYS ID to mitigate duplicates and omissions of individuals with the same name.


table: cmdb_ci_business_app
business owner: owned_by
IT Application Owner: it_application_owner

 

owned_by.jpg

 

it_application_owner.jpg

 

 

1 ACCEPTED SOLUTION

Najmuddin Mohd
Mega Sage

Hello @Bryant9 ,

You can achieve this using a script.
Check the below script:

(function() {
		
		var userList = [];
		var taskGr = new GlideRecord("cmdb_ci_business_app");  // Table name
		taskGr.addEncodedQuery('install_status!=3') // Conditions for filtering
		taskGr.query();
		while (taskGr.next()) {
			var ownedBy = taskGr.owned_by;   // Business Owner
			if (ownedBy && ownedBy.toString())      
				userList.push(ownedBy.toString());
			var itApplicationOwner = taskGr.it_application_owner;  // IT Application Owner
			if (itApplicationOwner && itApplicationOwner.toString())
				userList.push(itApplicationOwner.toString());
		}
		var uniqueUserList = new global.ArrayUtil().unique(userList);  // Unique from the Array created
		var obj = {'internal' : uniqueUserList};
		return obj;
})();



NajmuddinMohd_3-1737831357485.png

NajmuddinMohd_1-1737831260233.png





NajmuddinMohd_2-1737831293987.png




If the above information helps you, Kindly mark it as Helpful and Accept the solution.
Regards,
Najmuddin.

View solution in original post

2 REPLIES 2

Najmuddin Mohd
Mega Sage

Hello @Bryant9 ,

You can achieve this using a script.
Check the below script:

(function() {
		
		var userList = [];
		var taskGr = new GlideRecord("cmdb_ci_business_app");  // Table name
		taskGr.addEncodedQuery('install_status!=3') // Conditions for filtering
		taskGr.query();
		while (taskGr.next()) {
			var ownedBy = taskGr.owned_by;   // Business Owner
			if (ownedBy && ownedBy.toString())      
				userList.push(ownedBy.toString());
			var itApplicationOwner = taskGr.it_application_owner;  // IT Application Owner
			if (itApplicationOwner && itApplicationOwner.toString())
				userList.push(itApplicationOwner.toString());
		}
		var uniqueUserList = new global.ArrayUtil().unique(userList);  // Unique from the Array created
		var obj = {'internal' : uniqueUserList};
		return obj;
})();



NajmuddinMohd_3-1737831357485.png

NajmuddinMohd_1-1737831260233.png





NajmuddinMohd_2-1737831293987.png




If the above information helps you, Kindly mark it as Helpful and Accept the solution.
Regards,
Najmuddin.

Works like a dream. Thank you, @Najmuddin Mohd!