- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2019 08:38 AM
Good morning everyone,
I'm trying to write a business rule that updates the Comments (Customer Visible) field with the information provided in the Close Notes field once the technician decides to resolve the ticket. I know this information can be seen in the Activity, however, I need the Comments field to be updated with the Close Notes field for my organization. I have provided a copy of my script, which should be simple but I'm having some trouble. The script is on the Incident table and runs on an update after Close Notes is not empty (I think that's correct):
(function executeRule(current, previous /*null when async*/) {
current.comments = current.close_notes.getDisplayValue();
})(current, previous);
Any help will be greatly appreciated!
Best regards,
cnharris
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2019 02:05 PM
Thanks Prateek! I tried using the code and it does work but it just doesn't work on the comments field for some reason. I think it has something to do with that field being an array but I'm not too certain. I did find a workaround to my problem and I provided the link below:
https://community.servicenow.com/community?id=community_question&sys_id=9997c7a9db1cdbc01dcaf3231f961933&view_source=searchResult
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2019 09:20 AM
Try changing the condition to Close Notes Changes and Script to the following
(function executeRule(current, previous /*null when async*/) {
current.comments = current.close_notes;
})(current, previous);
Please mark my response as correct and helpful if it helped solved your question.
-Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2019 02:05 PM
Thanks Prateek! I tried using the code and it does work but it just doesn't work on the comments field for some reason. I think it has something to do with that field being an array but I'm not too certain. I did find a workaround to my problem and I provided the link below:
https://community.servicenow.com/community?id=community_question&sys_id=9997c7a9db1cdbc01dcaf3231f961933&view_source=searchResult
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2019 02:08 PM
Glad that you were able to resolve.
Please mark the appropriate response as correct/helpful and close this thread.
-Cheers
Prateek
Please mark my response as correct and helpful if it helped solved your question.
-Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-27-2024 08:15 PM
For anyone that may need this in future:
in your business rule, set the condition for your use case, e.g. Incident State changes to Resolved
in your script, use the setJournalEntry method to update the comments field:
(function executeRule(current, previous /*null when async*/) {
// Add your code here
current.comments.setJournalEntry(current.close_notes, current.assigned_to);
})(current, previous);
Regards,
Yong Zeng