Service Request requester and approver should not be the same person

Steven31
Tera Contributor

Hi,

I'm building a service request to allow requester to manual select approver from user table. However I want to restrict requester to select ownself as approver. Any suggestion how can I build it? Thanks.

1 ACCEPTED SOLUTION

palanikumar
Giga Sage

Hi,

You can add following reference qualifier to your approver variable. Once this is added current user will not be listed in the variable

javascript:"sys_id!=" + gs.getUserID();

Thank you,
Palani

View solution in original post

6 REPLIES 6

AnubhavRitolia
Mega Sage
Mega Sage

Hi Steven,

You can right Business Rule on Approval Table to validate that Approver is not same as Approval for.Requester. In that case it should AboutAction.

Please mark this as correct answer if it resolved, or mark this helpful if this help you to reach towards solution.

Please mark this as correct answer and helpful if it resolved, or mark this helpful if this help you to reach towards solution.

Thanks
Anubhav Ritolia
ServiceNow Rising Star 2023

Mohith Devatte
Tera Sage
Tera Sage

hello Steven,

you can write an on change client script on the approver field for this thing 

Assuming this is a service catalog and requestor is the logged in user i can give your this below script

function onChange(control, oldValue, newValue, isLoading) {
	if (isLoading || newValue == '') {
		return;
	}
	if(newValue==g_user.userID)
{
alert('You cant select yourself as approver')
g_form.clearValue('your_approver_field_name');
}
}

Hope this helps 

PLEASE MARK YM ANSWER CORRECT IF THIS HELPS YOU

Thanks @Mohith Devatte, I've used Reference qualifier to eliminate requester name from selection.

suvro
Mega Sage
Mega Sage

whenever user selects the approver you can write an OnChange Client script to check 

 

if (newValue == g_user.userID){

clear that field and display error msg

}