Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-08-2025 12:29 AM
I have created an script include to get approver sys_id and I'm getting too.
below is the BR
var approvers = new csmCategoryApproval().getCategory(current.variables.category_cost);
gs.info("approvers);
if (approvers.length > 0) {
var gr = new GlideRecord('sysapproval_approver');
for (var i = 0; i < approvers.length; i++) {
gr.initialize();
gr.sysapproval = current.sys_id;
gr.document_id = current.sys_id;
gr.source_table = 'sn_customerservice_north_america_procurement';
gr.approver = approvers.toString()[i];
gr.state = 'requested';
gr.insert();
}
}
Output:
gs.info("approvers); is giving sys_id of users as below
ddfce96a47465e1060c8dbab416d43d0,886fcf1b87cd6910deb275d8dabb35aa,e99c513bdbfe270063c1c7ec0b96195f,07caf55f47da5690fbbf4d89116d4352,078e26914f68b60855699efd0210c7c9,051ba91f47565690fbbf4d89116d43db,17c0030013875b8436db33228144b025,73952025db81e34063c1c7ec0b961913
But when I'm check the case there are multiple approvals are getting added with blank approver
Solved! Go to Solution.
1 ACCEPTED SOLUTION
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-08-2025 12:44 AM
var approvers = new csmCategoryApproval().getCategory(current.variables.category_cost);
gs.info("approvers);
if (approvers.length > 0) {
var gr = new GlideRecord('sysapproval_approver');
for (var i = 0; i < approvers.length; i++) {
gr.initialize();
gr.sysapproval = current.sys_id;
gr.document_id = current.sys_id;
gr.source_table = 'sn_customerservice_north_america_procurement';
gr.approver = approvers[i];
gr.state = 'requested';
gr.insert();
}
}
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-08-2025 12:44 AM
var approvers = new csmCategoryApproval().getCategory(current.variables.category_cost);
gs.info("approvers);
if (approvers.length > 0) {
var gr = new GlideRecord('sysapproval_approver');
for (var i = 0; i < approvers.length; i++) {
gr.initialize();
gr.sysapproval = current.sys_id;
gr.document_id = current.sys_id;
gr.source_table = 'sn_customerservice_north_america_procurement';
gr.approver = approvers[i];
gr.state = 'requested';
gr.insert();
}
}