Transfer the owner of catalog items if the owner is deactivated in ServiceNow

Pooja Khatri
Tera Contributor

Hello , 

 

I have a requirement , where if the owner of the catalog item becomes inactive then the catalog item ownership should be transferred to the Manager of the assignment group to which the catalog item is assigned .

 

How can I implement this functionality  ?

3 REPLIES 3

Johns Marokky
Tera Guru

Hi @Pooja Khatri ,

I was searching in Catalog Item. but I am not able to find the Assignment group field. As you mentioned that the catalog Item is assigned to the Assignment group, is it a custom field created?

 

In that case, you can write a business rule and achieve this. If you need more help on this can you please provide the conformation of the Assignment group field name and where its located, so I can develop and give the script.

 

Mark helpful if it helps in solving your query.

 

Regards,

Johns

Hi @Johns Marokky  .. yes the assignment group field is a custom field .. the name of the field is Assignment group itself and it is located in sys_user_group table itself ..  yes can you please help me with the script . 

 

Hi @Pooja Khatri,

Please create a business rule on the sys_user with a filter as Active is false table as per the below image.

Screenshot 2023-01-27 at 8.30.55 PM.png

 

go to advanced and add the condition as per below script.

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

	// Add your code here
	var catGr = new GlideRecord('sc_cat_item');
	catGr.addQuery('owner',current.sys_id);
	catGr.query();
	while(catGr.next()){
		catGr.owner = catGr.u_assignment_group.manager;     //give the correct field name for assignment group
		catGr.update();
	}

})(current, previous);

 

I think this would help in solving your query.

 

Mark helpful and correct if it helps in solving your query.

 

Regards,

Johns