How to attach an onSubmit script to work_notes/comments fields in Incident?

rs111
Kilo Explorer

I can create an onSubmit client script for the Incident view, and it runs if I click "Update" in the top right.

However, it does not run if I use "Post" which is right next to the work_notes and/or comments field in the incident 'feed' section.

How do I connect to this Post button so I can also run my script if that is clicked instead of Update?

15 REPLIES 15

rs111
Kilo Explorer

ramireddy - Did I see in email that you had posted a reply, but now I don't see it here. Did you remove it or should it work?




"Those work_notes/comments will be stored in sys_journal_field table. So, you can create a client script for this table and implement 'onsubmit' event.



To connect both these scripts, you can put your code inside a javascript function and call that function in both places. As it's javascript and in same page, function should be shared across both client scripts."


Post does not update your form, so the onSubmit client script is not triggered. Not sure if this can be coded using DOM manipulation and triggering an onclick event


rs111
Kilo Explorer

I tried a desktop onSubmit global in sys_journal_field as follows, but it doesn't appear to have fired based on the console.


function onSubmit() {
      var sFieldValue = g_form.getValue("work_notes");
      console.log("GOT: Journal Entry: " + sFieldValue);
}

Work_notes does not store any values. You will have to move this to business rule;e and use getJournalEntry() to get the entries. Following link will be helpful


Using Journal Fields - ServiceNow Wiki