Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

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

Thanks for the hint, I did not manage it to work on Jakarta. I can successfully locate Button Element and attach my event, but it doesn't get fired. The reason is probably the fact, the implementation of Angular directive ng-click the function postJournalEntryForCurrent contains code line: event.stopPropagation();

The maximum I achieved is turn the button entirely off:

function onLoad() {
	
	var btnPost = document.getElementsByClassName('activity-submit')[0];
	
	btnPost.setAttribute('ng-click', '');
	btnPost.setAttribute('ng-keypress', '');
	
	btnPost.setAttribute('style', 'display:none;');
}