Need to show the delegate approval comments in Approvers Tab in Change request
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-15-2024 08:18 AM - edited 06-15-2024 08:52 AM
Required help @Vasantharajan N @Ankur Bawiskar @Geoffrey2 @Arjun Reddy Yer
As when the change request is approved by Delegate Approver then in the comments section of the Approvers Tab need to show as the "<Time Stamp> Change Request is Approved by Delegate Approver <Approver Name>".
As of now when an Delegate Approver is approving the change request in the comment section it's not showing anything as mentioned below & the Delegate Approved one is showing as false.
To get the comments tried with Business Rule as mentioned below
Business Rule:
Script:
(function executeRule(current, previous /*null when async*/ ) {
var user, delegate;
var gr = new GlideRecord('sys_user');
if (gr.get('user_name', current.sys_updated_by)) {
user = gr.name;
}
var grd = new GlideRecord('sys_user_delegate');
grd.addQuery("user", current.approver);
grd.addQuery("approvals", "true");
grd.addQuery("starts", "<=", gs.daysAgoEnd(0));
grd.addQuery("ends", ">=", gs.daysAgoStart(0));
grd.query();
while (grd.next()) {
delegate = grd.delegate.getDisplayValue();
}
if (user == delegate) {
if (current.state.changesTo('approved')) {
current.comments.setJournalEntry = "The request has been approved by delegate " + user;
} else if (current.state.changesTo('rejected')) {
current.comments.setJournalEntry = "The request has been rejected by delegate " + user;
}
} else {
if (current.state.changesTo('approved')) {
current.comments = "The request has been approved by " + user
} else if (current.state.changesTo('rejected')) {
current.comments = "The request has been rejected by " + user;
}
}
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2024 01:35 AM
@Sony Doddapanen - I don't see any problem with your script. Are you seeing comments as per your need in the actual approval record?
Thanks & Regards,
Vasanth