Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to skip RITM approval if Manager is the Requested By

Joe Weisiger
Giga Expert

Hello,

I have a catalog item where I have created a reference variable called "Requested by".  If this field is the same user that the approval is going to I want the approval skipped.  

How do I accomplish this?

Thank you in advance!

Joe

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@Joe Weisiger 

You can use If activity with script just before your actual approval and return yes or no

if activity script

answer = ifScript();

function ifScript(){

// your logic to determine the approver here

var approver = 'your value';

if(current.request.requested_for == approver)

return 'no'; // output of this goes to next activity by skipping approval

else

return 'yes'; // output of this goes to approval activity

}

Regards
Ankur

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

View solution in original post

12 REPLIES 12

Thanks Ankur,

We have a variable on the item called requested_by.

The approver(s) will come from a field called u_customer_approvers on the customer account form.

I tried the below and it did not work.  It didnt throw an error, but it requests an approval even when 'requested_by' is the same person in the 'customer approvers' field.

answer = ifScript();

function ifScript(){

// your logic to determine the approver here

var approver = customer_account.u_customer.approvers;

if(current.variables.requested_by == approver)

return 'no'; // output of this goes to next activity by skipping approval

else

return 'yes'; // output of this goes to approval activity

}

@Joe Weisiger 

try to update as this

answer = ifScript();

function ifScript(){

// your logic to determine the approver here

var approver = customer_account.u_customer.approvers;

if(current.variables.requested_by == approver)

return 'no'; // output of this goes to next activity by skipping approval

else

return 'yes'; // output of this goes to approval activity

}

Regards
Ankur

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

abhijitkhewale
Mega Expert

Logic provided by @Ankur Bawiskar is correct, I have below suggestions for you

1) Check value current.variables.requested_by it will be sys_id if reference field, check value of approver is it sys_id?

2) Requsted By is available on Request form directly hence it is referred as 

current.request.requested_for

but you are referring to variables -current.variables.requested_by which would have catalog item values

 

Please cross check it