- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-13-2015 11:53 AM
I'm trying to script an approval in a workflow on the request item table. Because the approving person changes based on another variable on the request we are simply using a variable. I've tried every way I could find in the wiki and the community, but every time the workflow hits this approval it just "skipped" and goes on to the next workflow step. Any help is greatly appreciated. Here is my script:
var answer = [];
var approver = new GlideRecord("sys_user");
approver.addQuery("user_name", current.variable_pool.who_approves);
approver.query();
while(approver.next()){
answer.push(approver);
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-13-2015 12:24 PM
- gs.log('David : Workflow variable print: ' + current.variable_pool.who_approves + ' ' + current.variable_pool.who_approves.getDisplayValue());
- var answer = [];
- var approver = new GlideRecord("sys_user");
- // approver.addQuery("user_name", current.variable_pool.who_approves); // It will return the sys id of the record variable referencing to
- approver.addQuery('sys_id',current.variable_pool.who_approves); // try this line or very next line to it.
- approver.addQuery('user_name',current.variable_pool.who_approves.getDisplayValue();
- approver.query();
- while(approver.next()){
- gs.log('David : Approver name is: ' + approver.user_name); // Always try to write down log statements to check the logic.
- answer.push(approver.sys_id);//corrected the last line as well.
- }
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-13-2015 12:24 PM
- gs.log('David : Workflow variable print: ' + current.variable_pool.who_approves + ' ' + current.variable_pool.who_approves.getDisplayValue());
- var answer = [];
- var approver = new GlideRecord("sys_user");
- // approver.addQuery("user_name", current.variable_pool.who_approves); // It will return the sys id of the record variable referencing to
- approver.addQuery('sys_id',current.variable_pool.who_approves); // try this line or very next line to it.
- approver.addQuery('user_name',current.variable_pool.who_approves.getDisplayValue();
- approver.query();
- while(approver.next()){
- gs.log('David : Approver name is: ' + approver.user_name); // Always try to write down log statements to check the logic.
- answer.push(approver.sys_id);//corrected the last line as well.
- }
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-13-2015 12:49 PM
I needed the .getDisplayValue(). It works now. Thanks for the input. You are correct about the gs.log. Thanks again!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-18-2016 08:02 AM
Hello,
So would just using this script generate an approval? I would not have to use the Approval - user activity?
Thanks
Ira