- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2018 10:55 PM
Hi All,
I would like to insert an approval using a BR. Please let me know how to achieve this.
I have a field ABC(glide_list), I want to add the approvers in this field as approvers when a change is completed.
Thanks in Advance
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-28-2018 11:29 PM
Hi,
Sorry below one is the corrected script:
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var app = current.u_groups;//Where groups are selected
gs.addInfoMessage(app);
var spl = app.split(',');
var len = spl.length;
for(var i=0;i<len;i++)
{
gs.addInfoMessage(i);
var m = new GlideRecord('sysapproval_group');
m.initialize();
m.parent= current.sys_id;
m.assignment_group = spl[i];
m.approval = 'requested';
m.insert();
}
})(current, previous);
Thanks,
Ashutosh
Don't forget to mark it as correct

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2018 11:42 PM
Hi
You can achieve, something similar. Please note, I haven't tested this.
var grouplist = [];
var group = current.variables.ABC.toString();
grouplist2 = group.split(',');
for (var i = 0; i < grouplist2.length; i++)
{
var m = new GlideRecord('sysapproval_approver');
m.initialize();
m.document_id = current.sys_id;
m.approver = grouplist2[i];
m.state = 'requested';
m.insert();
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2018 11:58 PM
I tried the above script but din't work
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-27-2018 12:01 AM
Since it Is a field, you can remove variables from the line. Have you put any logs
var group = current.variables.ABC.toString(); to
var group = current.ABC.toString();

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-27-2018 12:17 AM
HI,
This is the below script which will work:
var grouplist = [];
var group = current.variables.ABC.toString();
grouplist2 = group.split(',');
for (var i = 0; i < grouplist2.length; i++)
{
var m = new GlideRecord('sysapproval_approver');
m.initialize();
m.sysapproval= current.sys_id;
m.approver = grouplist2[i];
m.state = 'requested';
m.insert();
}
}
Thanks,
Ashutosh Munot