incident Additional comments should capture in clode notes
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-17-2023 03:38 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-17-2023 05:38 AM - edited ‎10-17-2023 05:39 AM
Hey @Arun61
The first thing I noticed is in many places you're trying to access 'caller id' and 'sys_updated_by' as variables instead of properties of current. For example, in your first if statement. Even after you correct this you'll have to dotwalk onto the user record if you want to compare sys_updated_by. Make sure that everything you're referencing is either a variable you've already defined or a property of something like current.
You should also use getValue unless you're dotwalking, and if you're dotwalking you should use toString or +''
Other than that the logic here seems sound. I'd wonder if people are ever going to be populating close notes themselves since your code would effectively overwrite anything someone manually put into the form.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-17-2023 08:11 AM - edited ‎10-17-2023 08:29 AM
Hello @Arun61 ,
Comment is a journal entry field. So you cannot access it as a string. You have to use '.getJournalEntry' method with parameter 1 to get the latest comment (.getJournalEntry(1)). And in sys_updated_by take the user_name of the user.
Refer to the below code for your requirement:-
(function executeRule(current, previous /*null when async*/ ) {
var com = current.comments.getJournalEntry(1); // get the latest comment
var inccomments = com.slice(com.indexOf(')') + 1).trim();//get the string part
if (sys_updated_by == current.caller_id.user_name) {
current.close_notes = "Customer cancellation" + "\n" + "Cancellation Reason : " + inccomments;
} else if ((current.callerid.ebond == true && current.sys_updated_by == current.caller_id.user_name)) {
current.close_notes = "system cancellation" + "\n" + "Cancellation Reason : " + inccomments;
} else if (current.sys_updated_by == current.assigned_to.user_name) {
current.close_notes = "Manual Cancellation" + "\n" + "Cancellation Reason : " + inccomments;
}
})(current, previous);
If this response clears up your doubt, kindly flag it as both helpful and correct.
Thanks,
Alka