Community Alums
Not applicable
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2025 06:21 AM
Hi Team,
I am trying to create approval record via Before Update Business rule as below . The record is getting created buts its creating Approving i.e Document_id as blank or empty even though I am passing the correct record or sys_id which is the current form on which the BR is written.
Below is the BR:
var users = current.users.split(',');
for (var i = 0; i < users.length; i++) {
var app = new GlideRecord('sysapproval_approver');
app.initialize();
app.state = 'requested';
app.approver = users[i];
app.document_id = current.sys_id;
app.insert();
}
Please help in resolving this?
Solved! Go to Solution.
1 ACCEPTED SOLUTION
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2025 06:56 AM
@Community Alums
try this -> you need to set the source_table as well
var users = current.users.split(',');
for (var i = 0; i < users.length; i++) {
var app = new GlideRecord('sysapproval_approver');
app.initialize();
app.state = 'requested';
app.approver = users[i];
app.source_table = current.getTableName(); // or give hard-coded table name on which BR is present
app.document_id = current.sys_id;
app.insert();
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Regards,
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2025 06:56 AM
@Community Alums
try this -> you need to set the source_table as well
var users = current.users.split(',');
for (var i = 0; i < users.length; i++) {
var app = new GlideRecord('sysapproval_approver');
app.initialize();
app.state = 'requested';
app.approver = users[i];
app.source_table = current.getTableName(); // or give hard-coded table name on which BR is present
app.document_id = current.sys_id;
app.insert();
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Regards,
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader