Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2024 10:44 PM
Sent by you:
In the Change Request table approver approval the change Approver is auto Populate description in service now how to achieve this?
Table Name: Change Request
After Business rule
record update time execution
var gr = new GlideRecord('sysapproval_approver');
gr.addQuery('sysapproval', current.sys_id);
gr.orderBy('approver');
gr.query();
if (gr.next()) {
current.setValue('description', gr.sys_id);
}
Solved! Go to Solution.
1 ACCEPTED SOLUTION
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2024 10:30 PM
I have found the answer to this question.
table name is
sysapproval_approver
- var gr = new GlideRecord('change_request');
- gr.addQuery('sys_id', current.sysapproval.sys_id);
- gr.addQuery('assigned_toISEMPTY^state=-4');
- gr.query();
- if (gr.next()) {
- gr.assigned_to = current.approver.toString();
- gr.update();
- }
3 REPLIES 3
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2024 07:06 PM
After insert --- update
You can try the below script :
(function executeRule(current, previous /*null when async*/) {
var gr = new GlideRecord('sysapproval_approver');
gr.addQuery('sysapproval', current.sys_id);
gr.addQuery('state','approved');
gr.query();
var approverList = [];
while (gr.next()) {
approverList.push(gr.getDisplayValue('approver'));
}
if (approverList.length > 0) {
var approvers = approverList.join(', ');
current.setValue('description', 'Approvers: ' + approvers);
current.update();
}
})(current, previous);
Thanks and Regards
Sai Venkatesh
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2024 07:09 PM
You can try the below script :
after ----update
(function executeRule(current, previous /*null when async*/) {
var gr = new GlideRecord('sysapproval_approver');
gr.addQuery('sysapproval', current.sys_id);
gr.addQuery('state','approved');
gr.query();
var approverList = [];
while (gr.next()) {
approverList.push(gr.getDisplayValue('approver'));
}
if (approverList.length > 0) {
var approvers = approverList.join(', ');
current.setValue('description', 'Approvers: ' + approvers);
current.update();
}
})(current, previous);
Thanks and Regards
Sai Venkatesh
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2024 10:30 PM
I have found the answer to this question.
table name is
sysapproval_approver
- var gr = new GlideRecord('change_request');
- gr.addQuery('sys_id', current.sysapproval.sys_id);
- gr.addQuery('assigned_toISEMPTY^state=-4');
- gr.query();
- if (gr.next()) {
- gr.assigned_to = current.approver.toString();
- gr.update();
- }