Best approach to assign a role to users for whom approval is triggered

geet
Tera Guru

Hi,

Is it a good approach to add approver_user role to the users record via a Business rule, if an approval has triggered for him/her.

Trying this way, but not sure if approach is correct or not.

find_real_file.png

find_real_file.png

find_real_file.png

 

Problem: Users are using ServiceNow mobile app to approve the tickets assigned to them for approval.

But they couldn't see any record under "My approval" in mobile app. I have read some community articles which say that giving approver_user role will solve the issue.

I have 10000 users in my instance and I am not sure how many use mobile app to approve and I can't go and assign approver_user role to everyone who comes individually to me. I want to automate the assignation of "approver_user" role.

My thought is that as soon as a record is inserted in sysapproval_approver table, it should check whether the approver has "approver_user" role or not. If user has approver_user role then it is fine, if the user doesn't have approver_user role then he should be provided "approver_user" role via a script.

I hope my approach is correct. Need suggestions for the same.

 

Regards,

Geet

 

3 REPLIES 3

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

there might be some licensing cost so please discuss with your business team around this.

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi Ankur,

 

We already discussed this and they are fine with providing approver_user role to the users for whom approval is triggered.

Is there any other approach that you can suggest for this kind of requirement?

Users want to see the data under "My approvals" in mobile app but they can't see because of lack of approver_user role.

 

 

Hi,

then update script as this

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

	// Add your code here
	var rec = new GlideRecord('sys_user_has_role');
	rec.addQuery('user', current.approver);
	rec.addQuery('role.name', 'approver_user');
	rec.query();
	if(!rec.hasNext()){
		rec.initialize();
		rec.user = current.approver;
		rec.setDisplayValue('role', 'approver_user');
		rec.insert();
	}

})(current, previous);

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader