How to update worknotes from script in flow designer ?

Thej1
Tera Expert

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 

7 REPLIES 7

Mark Manders
Mega Patron

You didn't ask me (and I am glad you didn't, because being tagged in questions is the worst!), but in what kind of field are you setting this? Is it directly in the work notes of the 'update record' action or as a flow variable? 

I think if you do it like this, you're there:

(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\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 will return you text, assuming you will have a previous assigned to, of course. If the issue is in that part, we need to pinpoint to the data that is coming into your flow.


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark

Hi,

 

Updating directly in the work notes of the 'update record' action. will try it.

 

Thanks 🙂 

Then this should work, unless it's in the previous.assigned_to part. 


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark

Not updating worknotes 😞