- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-10-2023 06:01 AM
I have a requirement. We have cancel Ui action on incident form when user clicks on cancel button then addition comment will be mandatory user enter cancellation reason.
Now we need to capture Cancellation reason in resolution note.
canceled by: - (if caller canceled then caller name or cancled by integration then system)
reason for cancellation: - (Additional comments)
Can anyone help on this.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-17-2023 04:20 AM
script is wrong.
alert won't work in business rule; also you are not comparing the value correctly
try this
(function executeRule(current, previous /*null when async*/ ) {
var inccomments = current.comments.getJournalEntry(1);
if (current.sys_updated_by == current.caller_id.user_name) {
current.close_notes = "Customer cancellation" + "\n" + "Cancellation Reason : " + inccomments ;
} else if ((current.caller_id.ebond == true && current.sys_updated_by == current.caller_id.user_name)) {
current.close_notes = "system cancellation" + "\n" + "Cancellation Reason : " + inccomments ;
gs.log("ebond" + current.u_customer);
} else if (current.sys_updated_by == current.assigned_to.user_name) {
current.close_notes = "Manual Cancellation" + "\n" + "Cancellation Reason : " + inccomments;
}
})(current, previous);
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-10-2023 06:28 AM
so what script did you start with and where are you stuck?
share the script and UI action screenshot
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-17-2023 02:38 AM - edited 10-17-2023 02:41 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-17-2023 04:20 AM
script is wrong.
alert won't work in business rule; also you are not comparing the value correctly
try this
(function executeRule(current, previous /*null when async*/ ) {
var inccomments = current.comments.getJournalEntry(1);
if (current.sys_updated_by == current.caller_id.user_name) {
current.close_notes = "Customer cancellation" + "\n" + "Cancellation Reason : " + inccomments ;
} else if ((current.caller_id.ebond == true && current.sys_updated_by == current.caller_id.user_name)) {
current.close_notes = "system cancellation" + "\n" + "Cancellation Reason : " + inccomments ;
gs.log("ebond" + current.u_customer);
} else if (current.sys_updated_by == current.assigned_to.user_name) {
current.close_notes = "Manual Cancellation" + "\n" + "Cancellation Reason : " + inccomments;
}
})(current, previous);
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-10-2023 06:35 AM
Hi,
If I read this correct then you need 'we need to capture Cancellation reason in resolution note.'
If so then you need to write a BR On the table in question
Condition - State <changes to><cancelled state>
and copy the Cancellation reason (Additional comment) to Resolution Note
canceled by: - You can again check if it is a user, and if not then add system
canceled by: This is same as Cancellation reason but if you need to do it again you can.