- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-20-2014 01:01 PM
Hello,
I'm new to ServiceNow and scripting so hopefully someone can point me in the right direction (we have Dublin). I am working on my first Service Catalog item and workflow (sc_req_item) and as a first step, I'm just trying to get 1 approval workflow activity to work. I have been scanning wikis and community posts but haven't found what I think I need yet. I did see a post that has some similarities - https://community.servicenow.com/message/689570#689570.
The catalog item that I'm creating is "Create an Oracle User" - the 2 questions (item variables in a variable set) that will be asked when the item is selected are "Requested For User" (requested on behalf of) and "Source User" (the new user will be created like this model source user). The "Requested For User" could be for the person who actually types in the request or could be for someone else. As a first step in the workflow, the manager (or supervisor) of the "Requested For User" has to give approval.
How can I get the "Requested For User" variable's value to be used for the manager/supervisor approval workflow activity? For example, if I am Jane Doe and I type in Jack Sprat in the "Requested For User" field, the request needs to approved by Jack's manager/supervisor. I think that I need to pass the variable's value from the catalog item to the workflow so that the manager approval activity will process with the correct person's manager. But I am confused on how to do this?
Thank you for any info you can provide (the more details the better since I'm a newbie)!
Solved! Go to Solution.
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-25-2014 11:38 AM
jlouie,
With what has been previously mentioned there is one piece to approvals that needs to be in there for it to actually assign an approval.
answer.push
try this:
answer = [];
var manager = current.variables.requested_for_user.manager.sys_id;
answer.push(manager);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-20-2014 01:23 PM
Assuming your variable is a reference to the user table, you can use an approval activity with the advanced checkbox and then the additional approvers script field to add the manager through a script:
answer = current.variables.requested_for_user.manager.sys_id;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-20-2014 02:40 PM
Hello b-rad,
Thanks for the reply! Yes, my requested_for_user variable is part of a variable set and it is referencing the sc_user table. I added this to my approval workflow activity in the additional approvers script section:
answer = current.variables.requested_for_user.manager.sys_id;
My simple workflow test only contains the 1 workflow manager approval activity, with stage = completed and both approved/rejected just going to the End. When I submitted the test of the catalog item for this workflow, the request just completed immediately and the approval activity shows result=skipped and state=finished. There are no approvers listed under the request either - I was hoping to see the manager of the requested_for_user there.
I must be missing something or configured something wrong?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-25-2014 11:38 AM
jlouie,
With what has been previously mentioned there is one piece to approvals that needs to be in there for it to actually assign an approval.
answer.push
try this:
answer = [];
var manager = current.variables.requested_for_user.manager.sys_id;
answer.push(manager);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-25-2014 02:02 PM
Hello,
I was able to get the approval activity to process correctly by putting these 2 lines in the additional approvers script field:
answer = [];
answer.push(current.variables.requested_for_user.manager.sys_id);
jeff.lord and b-rad:
Thanks so much for answering my posting and helping guide me in the right direction!