How to insert close notes in a notification

redth
Giga Expert

Hello,

I need to insert close notes (present in the task table) in the notification which was built on requested item table.

Can you let me know how to achieve this?

Best,

Akshitha

1 ACCEPTED SOLUTION

Thanks for the clarification. In your message HTML include this:



Close notes: ${mail_script:task_close_notes}



Navigate to System Notification> Email> Notification Email Scripts and create a new record with the name: task_close_notes.



For the script: use this



var scTask = new GlideRecord('sc_task');


scTask.addQuery('request_item',current.getValue('sys_id'));


scTask.query();



if (scTask.next()) {


  if (scTask.closed_notes != "") {


      template.print(scTask.getValue('closed_notes');


  }


}


View solution in original post

19 REPLIES 19

Are you sure there is a valid value in the field? If so, how?


Yes, it's a valid value.


Even though I enter the comments in the close notes, it's not being populated in the notification.


I have attached a screenshot for your reference.Close notes.PNG


nthumma
Giga Guru

You need to write a mail script which queries the task table and gets notes and call that mail script from your notification.


Hello,



Can you guide me in building the mail script?



Best,


Akshitha


under System Notification --> Notification Email Scripts -> New



Name:YourScriptName


coy below code and make neccessary changes based on your requirement.


      var gr = new GlideRecord('Your_Task_Table');


  gr.addQuery('your_parent_field_name',current.sys_id);


  gr.query();


  while(gr.next()) {


  if(gr.closed_notes != "")


  {


  template.print('<li>Closed Notes: ' +gr.closed_notes+ '</li>');


  }


  }



and in the notification call the mail script like below


<p>${mail_script:YourScriptName}</p>