Need to get the value
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2024 02:26 AM
Hello Community,
I am getting the sys_id in the approval field, though it has referenced to sysapproval_approver table.
Could anybody help to get the value instead of sys_id.
Below is the script, I am using ; -
- 511 Views
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2024 02:29 AM
Try this
(function executeRule(current, previous /*null when async*/ ) {
// check if the state is being set to reffered back
var count = current.u_rejected_count;
if (current.state == 'rejected' && previous.state != 'rejected') {
current.u_rejected_count = count + 1;
var gr = new GlideRecord('u_m2m');
gr.addQuery('u_approval', current.sys_id);
gr.query();
if (gr.next()) {
gr.u_refer_back_code=current.u_refer_back_code;
gr.u_reason_refer_back=current.u_refer_back_reason;
gr.u_refer_back_count = current.u_rejected_count;
gr.update();
} else {
var gr1 = new GlideRecord('u_m2m');
gr1.initialize();
gr1.u_approval = current.getDisplayValue();
gr1.u_approval_for = current.document_id.getValue();
gr1.u_refer_back_code=current.u_refer_back_code;
gr1.u_reason_refer_back=current.u_refer_back_reason;
gr1.u_refer_back_count = current.u_rejected_count;
gr1.insert();
}
}
current.update();
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2024 02:50 AM
Hello @Anurag Tripathi ,
Thanks for your prompt response, but now when I am using below code, I am not getting anything in approval field as attached in the screenshot. Also, could you please help to populate the document Id field as well coming from 'sysapproval_approver' table.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2024 02:52 AM
What is your current here? what table is the BR running on?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2024 02:55 AM
It is running on sysapproval_approver table.