How to update worknotes from script in flow designer ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-13-2024 02:11 AM - edited 08-13-2024 02:16 AM
Hi,
I am trying to update the Work notes of incident from the flow designer. Somehow it is not updating the worknotes when triggered.
Here is the script
(function() {
var workNotes = '';
if (fd_data.trigger.previous.assigned_to) {
var assignedToGr = new GlideRecord('sys_user');
if (assignedToGr.get(fd_data.trigger.previous.assigned_to)) {
var assignedToName = assignedToGr.name.getDisplayValue();
workNotes = 'Dear ' + assignedToName + ',\n\n' +
'Please note that the customer has escalated this incident. The ticket has been reassigned to the ABCD for further handling. The ABCD will reach out to the team lead to clarify the situation and agree on a resolution plan.\n\n' +
Best regards
}
}
if (workNotes) {
fd_data.current.work_notes = workNotes;
}
return fd_data.current.work_notes;
})();
Please help me on this.
Thanks
@Community Alums @Sohail Khilji @Sid_Takali
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-13-2024 03:03 AM
What does your flow execution say?
You could add logging to see where the issue is. Can you confirm that you do have that previous assigned_to?
You could make this the script:
(function() {
var workNotes;
var assignedToName;
if (fd_data.trigger.previous.assigned_to) {
var assignedToGr = new GlideRecord('sys_user');
if (assignedToGr.get(fd_data.trigger.previous.assigned_to)) {
assignedToName = assignedToGr.name.getValue();
} else {
assignedToName = 'undefined';
}
}
workNotes = 'Dear ' + assignedToName + ',\n\nPlease note that the customer has escalated this incident. The ticket has been reassigned to the DISC for further handling. The DISC will reach out to the team lead to clarify the situation and agree on a resolution plan.\n\nBest regards,\nJarvis';
}
if (workNotes) {
return workNotes;
}
})();
This should fill your worknotes no matter what and gives you a clue into where to look.
Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-13-2024 08:20 AM
Hi Mark,
I have kept logs and checked. It is not getting the value of previous.assigned_to as does in Business Rule.
Hence, created a new field on incident form and stored previous assigned to from BR.
Then tested. In logs i can see that worknotes is correctly constructed but not updating in ticket. Them removed function from code and tested. Then worked fine.
Thanks 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-14-2024 03:34 AM
So removing the last 'if' did the job?
Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark