How to Assign the Requester's Manager to a Request Item (RITM) for Approval.

humblecommitted
Kilo Guru

Hello Community,

I tried following this forum but it didn't work for me:

How to add Manager Approval in workflow based on custom item variable

So what I want to do is for the manager field of a request, I would like that manager that is filled out in that field to be the RITM is assigned to for approval:

I have supplied the following screen shots below:

Here is the Request form:

3.jpg

Here is the name of the manager field:

3.1.jpg

Here is where I want to populate the "Assigned to" field to what was populated in the managers field from the request form:

3.2.jpg

Here is the work flow associated with the Request:

1.jpg

I tried putting in this code to have it transfer the manager variable to the "Assigned to" field of the request:

2.jpg

Please let me know what I am doing wrong.   Any help would be greatly appreciated.

1 ACCEPTED SOLUTION

Hello Everyone,



So I was able to resolve this by doing the following:



I created the following items on the work flow:


1.jpg


The script for the Run Script:



assigntomanager();


function assigntomanager() {


gs.log("Assigning Request Item to Requester's Manager");


//var assigntomanager = new GlideRecord('sc_rq'); no need to make glideRecord, your workflow is on sc_req_item table so current refers to current record of //sc_req_item itself



//assigntomanager.current.assigned_to = current.variables.manager; // no need to add assigntomanager before current object, wrong syntax


current.assigned_to = current.variables.manager ; // correct syntax


}


3.jpg


and I had to use a script since the approver of the request could change and the variable field was dynamic.   The Advance script for the Approval - User:


// Set the variable 'answer' to a comma-separated list of user ids and/or group ids or an array of user/group ids to add as approvers.


//


// For example:


//gs.log("starting approval script");


            answer = [];


//             answer.push('current.variables.manager');


          answer.push(current.variables.manager);






//answer = current.variables.manager;




//gs.log(" variable is " + current.variables.manager + " answer is " + answer);


2.jpg



now the manager of the requested_for user will be set as the approve on the Request Item (RITM).



Thank you all for your assistance.


View solution in original post

8 REPLIES 8

So when I tried to use the wait for condition, it works and awaits for the manager to approve it.   However, the approval email is not sent to the manager.


giriprasad9
Tera Expert

Hi Orlando,



In work flow your using "Approval - Group" activity. Can replace it with "Approval - User" activity.



find_real_file.png



Approval - Group   -->   If you need approval from group


Approval - User   -->   if you need approval from individual users



You need approval from manager(user), so you need to use "Approval - User" activity.




If this resolves your issue then please mark post as correct answer.



-Giri


Thank you Giri,



I have swapped the approval group, to approval user.   However the approval user is based on the variable name that is filled out in the request so I had to use a script to assign rather than looking for one person all the time to assign these request to.


Hello Everyone,



So I was able to resolve this by doing the following:



I created the following items on the work flow:


1.jpg


The script for the Run Script:



assigntomanager();


function assigntomanager() {


gs.log("Assigning Request Item to Requester's Manager");


//var assigntomanager = new GlideRecord('sc_rq'); no need to make glideRecord, your workflow is on sc_req_item table so current refers to current record of //sc_req_item itself



//assigntomanager.current.assigned_to = current.variables.manager; // no need to add assigntomanager before current object, wrong syntax


current.assigned_to = current.variables.manager ; // correct syntax


}


3.jpg


and I had to use a script since the approver of the request could change and the variable field was dynamic.   The Advance script for the Approval - User:


// Set the variable 'answer' to a comma-separated list of user ids and/or group ids or an array of user/group ids to add as approvers.


//


// For example:


//gs.log("starting approval script");


            answer = [];


//             answer.push('current.variables.manager');


          answer.push(current.variables.manager);






//answer = current.variables.manager;




//gs.log(" variable is " + current.variables.manager + " answer is " + answer);


2.jpg



now the manager of the requested_for user will be set as the approve on the Request Item (RITM).



Thank you all for your assistance.