how to generate approval using script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-14-2017 05:54 AM
can you please confirm, how to generate approval using script
i've used the approval user activity, but in my requirement i need to add approvals based on the users selected in List collector.
so the approvals approved in first iteration gets removed after approval.
is there a way to come around this? please advise
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-14-2017 05:59 AM
Hi Carmel,
It's going to look something like this:
answer = getApprovers();
function getApprovers() {
var appList = [];
var uListStr = current.getValue('u_list'); // Use your list collector here
uList = uListStr.split(',');
for (var i = 0; i < uList.length; i++) {
appList.push(uList[i]);
}
return uList;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-14-2017 06:10 AM
Hi Chuck,
in the above example which you've given it's actually using the approval workflow activity
i've done the same but when i add users 1,2 in the first iteration of my loop, it's gets added but when the same activity is again gets called the first approval from 1,2 gets removed from the approval list
if you can see the screenshot you can see a workflow loop using of condition

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-14-2017 06:15 AM
Hi Carmel,
If I recall, hitting an approval activity multiple times resets the approval, so that makes sense that your first two users are removed when it gets hit a second time.
Any time you are going 'back' in a workflow, I recommend using the RollBack To activity. Take a look at it and understand if it is what you need.
http://wiki.servicenow.com/index.php?title=Designing_Workflows_with_Rollback_To#gsc.tab=0
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-14-2017 06:22 AM
Hello Chuck ,
sorry i did not explain it clearly.
my requirement is like this:
Iteration1 ) two users were added to approval ( user 1, User 2) - User 1 approves the approval ( any one can approve)
iteration 2) two users were added to approval ( user 3, User 4) - User 4 approves the approval ( any one can approve)
now if i try to see who has approved in iteration 1) i have no clue as it's removed from the list
iteration 3) two users were added to approval ( user 5, User 6) - User 5 approves the approval ( any one can approve)
now if i try to see who has approved in iteration 2) i have no clue as it's removed from the list
at any time i need to see all list of approvers who has approved , if i use Roll back, will i be able to see complete list of users approved in all my iterations given in above example ?
i want to find an alternative way to see all approvers.
please confirm.
Thanks,
Carmel