How to attach an onSubmit script to work_notes/comments fields in Incident?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-04-2016 02:42 PM
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?
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-05-2016 08:12 AM
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." |

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-05-2016 08:18 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-05-2016 08:25 AM
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);
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-05-2016 08:28 AM
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