- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-25-2024 04:57 AM
Hello Everyone
I am trying to update a case record work notes with approver name who has approved / rejected a case.
When a case is rejected, rejection comments needs to added in the work notes of a case.
Could any one please help me to achieve it ? (please refer attached screenshot)
Thanks in advance
Nagurbi
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-25-2024 06:45 AM - edited 10-25-2024 06:46 AM
here is a sample, you can add more conditions and refine it as needed
(function executeRule(current, previous /*null when async*/) {
var grec = new GlideRecord("change_request");
grec.addQuery("sys_id", current.sysapproval);
grec.query();
if (grec.next()) {
grec.work_notes = 'Action by = '+current.approver.getDisplayValue() ;
grec.update();
}
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-25-2024 06:51 AM
Hi @Nagurbee1 ,
Please follow the steps below that I've completed for the change request table. You can replace the change request with the case table in the GlideRecord object.
Establish a business rule on the sysapproval_approver table that activates when the state changes to either approved or rejected.
In the script, we will use GlideRecord to ensure that the changes apply exclusively to the specified table and will update the work notes accordingly.
Output :
You can modify the business rule condition according to your needs; this is just an example of how to achieve your requirements.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If you found my response **helpful**, I’d appreciate it if you could take a moment to select **"Accept as Solution"** and **"Helpful"** Your support not only benefits me but also enriches the community.
Thank you!
Moin Kazi
www.linkedin.com/in/moinuddinkazi
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-25-2024 06:51 AM
Hi @Nagurbee1 ,
Please follow the steps below that I've completed for the change request table. You can replace the change request with the case table in the GlideRecord object.
Establish a business rule on the sysapproval_approver table that activates when the state changes to either approved or rejected.
In the script, we will use GlideRecord to ensure that the changes apply exclusively to the specified table and will update the work notes accordingly.
Output :
You can modify the business rule condition according to your needs; this is just an example of how to achieve your requirements.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If you found my response **helpful**, I’d appreciate it if you could take a moment to select **"Accept as Solution"** and **"Helpful"** Your support not only benefits me but also enriches the community.
Thank you!
Moin Kazi
www.linkedin.com/in/moinuddinkazi
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-25-2024 08:45 AM
Hello Moin
Thank you so much for your solution, it has worked for me and accepting your solution.
Thank you
Nagurbi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-25-2024 07:06 AM
Hi @Nagurbee1 ,
Do the following.
1. create one Async BR.
Code
var grec = new GlideRecord("change_request"); // replace with your table name
grec.addQuery("sys_id", current.document_id);
grec.query();
if (grec.next()) {
grec.work_notes = 'Approval comment: ' + current.comments.getJournalEntry(1);
grec.update();
}
-------------------------------------------------------------------------
If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.
Regards
Runjay Patel - ServiceNow Solution Architect
LinkedIn: https://www.linkedin.com/in/runjay
YouTube: https://www.youtube.com/@RunjayP
-------------------------------------------------------------------------