- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-01-2016 06:39 PM
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:
Here is the name of the manager field:
Here is where I want to populate the "Assigned to" field to what was populated in the managers field from the request form:
Here is the work flow associated with the Request:
I tried putting in this code to have it transfer the manager variable to the "Assigned to" field of the request:
Please let me know what I am doing wrong. Any help would be greatly appreciated.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-08-2016 01:06 PM
Hello Everyone,
So I was able to resolve this by doing the following:
I created the following items on the work flow:
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
}
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);
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-01-2016 07:32 PM
Hi Orlando,
You want to set the RITM "Assigned To" field to the manager variable on the form.
What you are trying in workflow is to trigger an approval for manager using approval group activity. First, for user approval (manager is user), you should use "Approaval user" activity and not "approval group". Second, if you want "assigned to" field on RITM to be same as manager variable, then you should do it via run script activity avaiable in the workflow.
Add the run script activity in your workflow at the appropriate place where you want assigned to field to be populated. Once done write down below line in script section which will set assigned to field to the manager variable on the form
current.assigned_to = current.variables.manager // I assume manager is the name of your variable.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-01-2016 07:47 PM
Hello Deepak,
If i were to script it would it be something along the lines of
assigntomanager();
function assigntomanager() {
gs.log("Assigning Request Item to Requester's Manager");
var assigntomanager = new GlideRecord('sc_rq');
assigntomanager.current.assigned_to = current.variables.manager;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-01-2016 08:19 PM
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
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-01-2016 10:34 PM
Hello Deepak,
That script worked and thanks for taking the time to explain and break it down for me. I understand a lot more about work flows for items now.
However I am left with one problem now. The request item doesnt wait for the manager to approve it, but instead completes the whole workflow as seen in the image below. Should I put in a wait condition?
Thanks in advance