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.

If requester is approver

sandeshraut198
Tera Contributor

Hi Community,

 

There is one catalog item in which requester is approver can we auto-approver this approver in workflow.

 

Thanks in advance.

9 REPLIES 9

Sohail Khilji
Kilo Patron

Hi @sandeshraut198 ,

 

 

I hope the catalog item will have a workflow associated to it... So in the approval activity you can create a script conditon to check if the requested for is same as approver or part of approval group. If yes the you can mark the state as approved if not then to requested state.

 

Ex: 

answer = ifScript();
 
function ifScript() {
var count = 0;
var grg = new GlideRecord('sys_user_grmember');
grg.addEncodedQuery('Group SysID');
grg.query();
while (grg.next()) {
if (grg.user.toString() == current.request.opened_by.toString()) {
count++;
}
}
if (count > 0) {
return 'yes';
} else {
return 'no';
}
}

☑️ Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....

LinkedIn - Lets Connect

Dnyaneshwaree
Mega Sage

Hello @sandeshraut198 , Please refer below images for your reference. It is working in my instance. If I am correctly understand your question, it might be help you.

Workflow activities:

Dnyaneshwaree_0-1710231421579.png

Script added in the highlighted "If" activity:

Dnyaneshwaree_1-1710231584671.png

Thank You!!

 




Please accept my solution if it works for you and thumps up to mark it as helpful.
Thank you!!

Dnyaneshwaree Satpute
Tera Guru

Mark Manders
Mega Patron

Shouldn't you make it that in this case the submitter can't approve it's own request? The approval process is there so someone with decision privileges can decide if someone else is eligible for what he is requesting. Just because you are given the privilege of approving it for others, doesn't make you eligible. Audit wise, approving your own request is a no-go. 


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark

Hi Mark,
For example, for UK customer, XYZ is the HR representative who approves all the "catalog item name", however he is usually also the one raising these requests herself.  Can we automate it somehow so that he would not have to approve her own request?

Yes, you can. Just put a validation in there that if the approval is for catalog item 'X' and the requested by is also the approver (but not the requested for), it get's approved. It would be easy in a flow, but in a workflow it can be done as well. You already received some answers on how to, but just make sure you are covered that someone does not approve for him/herself.


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark