- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-15-2024 09:00 AM
Required help @Vasantharajan N @Ankur Bawiskar @Geoffrey2 @Sony Doddapanen
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);
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-15-2024 01:13 PM
Hi @Arjun Reddy Yer,
You may try using current.update() after assigning value to the comments.
here is a link which you can refer: https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0715782#:~:text=Description,t....
You may utilize the below code for the same
current.setWorkflow(false);
current.update();
current.setWorkflow(true);
Please mark it helpful and try to give it a thumbs up if the above helps. Please accept the solution.
Thanks & Regards
Tabassum Sultana
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-15-2024 01:13 PM
Hi @Arjun Reddy Yer,
You may try using current.update() after assigning value to the comments.
here is a link which you can refer: https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0715782#:~:text=Description,t....
You may utilize the below code for the same
current.setWorkflow(false);
current.update();
current.setWorkflow(true);
Please mark it helpful and try to give it a thumbs up if the above helps. Please accept the solution.
Thanks & Regards
Tabassum Sultana