I was recently doing some research on g_form methods that ServiceNow provides to display messages on the form. The main two that I was familiar with were “addInfoMessage” and “addErrorMessage”; but what if there were more? I have definitely seen other messages displayed that was neither of these two… After doing some digging for the “hidden” method I was rewarded. The new method I found was called “_addFormMessage”. Note that this is not documented and is prefixed with an underscore indicating that it was meant to be used as an internal ServiceNow method so it is subject to change although it has been there since at least Eureka if that tells you anything :). Enjoy!

g_form._addFormMessage('Testing a form message at the top');

Ok, so that’s fine and dandy, but what if at some point in the future ServiceNow did deprecate this command; here’s one way you could re-implement it yourself using jQuery. Note that in order to make the command accessible via “g_form” we need to create it as a function off of the GlideForm object:

String.prototype.capitalizeFirstLetter = function() {
	return this.charAt(0).toUpperCase() + this.slice(1);
};

GlideForm.prototype.setNewFormMessage = function (message) {
	var tableId = g_form.getTableName().toString().capitalizeFirstLetter();

	var htmlBlock = '
' + message + '
'; jQuery("[tab_caption=" + tableId + "]").after(htmlBlock); }; var message = 'testing 123'; g_form.setNewFormMessage(message);