The CreatorCon Call for Content is officially open! Get started here.

Script for manager approval

anurima
Kilo Contributor

I am trying to write to manage approval script in which if a manager raises a request on behalf of his/her reportee then it should skip the manager's approval who is raising it and instead it's approval should go Manger's manager.

4 REPLIES 4

Coleton
Kilo Guru

Check if the 'Requested By' is the same value as the 'Requested For's manager. You can dot walk in the script. If it is, then take the 'Requested by' and send the approval to that user's manager.

ggg
Giga Guru

1) how do you know who the manager's reportees are?

2) how do you know who the manager's manager is?

Barbara L - Gli
Tera Guru

You need an If activity before your approval to check for the manager. If the user is in a variable on your item, it would look something like this: 

answer = ifScript();
function ifScript() {
	if(current.variables.user_variable.manager == current.request.requested_for) {
		return 'yes';
	} else {
		return 'no';
	}
}

Then if yes, skip the approval and go to the managers manager approval

SanjivMeher
Kilo Patron
Kilo Patron

You need a Run script activity in your workflow , just before the approval activity. 

 

The script should be

if (current.variables.requested_for.manager == current.opened_by)

workflow_scratchpad_approver = current.opened_by.manager;

else

workflow.scratchpad.approver = current.opened_by;

 

Then use the workflow.scratchpad.approver in your approver-user activity to set approval

Something like answer = workflow.scratchpad.approver;

 

 

 


Please mark this response as correct or helpful if it assisted you with your question.