Auto-approve request when the requested_by itself is the approver (Line manager) of the request in Service catalog.

Krish23
Tera Contributor

Hi Every one,

I need some help on the below scenario.

I am not a developer and trying to set up the workflow for : Auto-approve request when the requested_by itself is the approver (Line manager) of the request in Service catalog.

This is with regards to approvals for adding members to assignment group, if the request is raised by the assignment group manager then it should not go for his approval ( it should skip his approval). if the request is raised by some user then it should go for assignment group manager's approval. Once he/she approves the user gets added to the group.

everything is working fine except the if condition script. always it is triggering approvals to assignment group manager.

with the information available on SNOW community, I am able to write the below code( using If condition), however this is not working as expected.

Workflow always goes to false condition. and even when manager raises the ticket, it is going back to him for approval.

We are trying to automate if the requested by is the group 

Code in the if condition:

answer = ifScript();

function ifScript() {
var reqFor = current.variables.requested_for;
var reqBy = current.variables.Requested_by;
var check = new GlideRecord('sys_user_group');
if(check.get(reqFor)) {
if(reqBy == check.manager)
return 'yes';
else
return 'no';
}
}

 

4 REPLIES 4

Brandon Barret1
Mega Sage

I had a recent project where this came up. For me, the opened_by requestor, if also the approver got an auto approval.

I had to compare the actual sys_ids for the condition to evaluate.

It was something like

var openedby =current.opened_by.sys_id + “”;

var manager = manager.sys_id + “”;

If (openedby != manager){

//approval code here

}

Allen Andreas
Administrator
Administrator

Hi,

You just need to create an If activity before you draw a line to your approval activity.

In the if activity, you'd simply do:

answer = ifScript();

function ifScript() {
if (current.opened_by == current.variables.requested_for.manager) {
		return 'yes';
	}
	return 'no';
}

Just replace requested_for with the variable name in your item(s) that has the requested for person in it (which I think I did for you?).

Then just draw a line past the approval activity if yes....and if no...draw line to approval activity.

Please mark reply as Helpful/Correct. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

Hi Krish,

I just wanted to check-in on this. Seems it's been 9 months. I believe my reply above resolved your issue and/or guided you correctly?

Please mark above reply as Correct, if so.

Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

Hi,

I just wanted to check in on this. If my reply helped guide you correctly, please mark it as Helpful & Correct.

Thank you!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!