Approver not showing up for a BR
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2024 08:04 AM
Hi All,
I have configured a BR for the Business Service Table and trying to fetch the approval from 'sysapproval_approver' table as shown below but unfortunately the 'approver' name is not showing up.
BR Conditions :::
BR Table : cmdb_ci_service_business
Condition : 'Phase' changes and 'State' is Published ( Business Service )
Script mentioned in the BR ( The approval is in the 'Requested' State ):::
var approver = new GlideRecord('sysapproval_approver');
if (approver.get('document_id', current.sys_id)) { // current.sys_id is the ID of the Business Service
//gs.info("Current Sys ID: " + current);
//gs.info("Am I inside this loop?...");
node.u_approver = approver.getValue('approver'); // Value not getting populated in the custom field
}
Any help would be quite helpful! 🙂
Thanks and Regards,
Saurabh Chatterjee
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2024 08:55 AM
Hello @chatsaurav19 ,
Try the below.
(function executeRule(current, previous /*null when async*/ ) {
// Add your code here
var approver = new GlideRecord('sysapproval_approver');
approver.addQuery('document_id', current.sys_id);
approver.query();
if (approver.next()) {
current.u_approver = approver.getValue('approver'); //why you are using node.<custom field> here
current.update();
}
})(current, previous);
// This is also works fine
/*if (approver.get('document_id', current.sys_id)) { // current.sys_id is the ID of the Business Service
//gs.info("Current Sys ID: " + current);
gs.info("Am I inside this loop?...");
var approver = approver.getValue('approver'); // Value not getting populated in the custom field
gs.info('Approver:'+approver);
current.update();
}
*/
Please Mark My Answer as Helpful and Accept as Solution, if you find this article helpful or resolves your issue.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-18-2024 03:47 AM