How to display message on form?

kasirao
Kilo Contributor

Hello Team

I would like to   show   message on top of   the form, before submitting.

My form is like this.

form1.PNG

I am new to ServiceNow please help me in this requirement.

12 REPLIES 12

ccajohnson
Kilo Sage

You will want to use an onSubmit Catalog Client Script:


Catalog client script creation


Within this, catalog client script, you will use the g_form.addInfoMessage() method:


GlideForm - Client


JJ1
Kilo Guru

Are you trying to show some validation messages ? if so you can use before insert business rules and add message and abort the action.


brendanwilson84
Kilo Guru

On load client script  





function onLoad() {


    //Type appropriate comment here, and begin script below


  g_form.addInfoMessage("your message");


}


ngovinddas
Tera Contributor

Hi KasiRao,



You may use OnDisplay Business Rule and display the message you wanted.


Firstly, you may need to choose Conditions for the Business to Run,


Secondly, Check the Advanced (to True) which will open up the Advanced Tab on the Business Rule form,


Here you may use the below snippnet



(function executeRule(current, previous /*null when async*/) {



// Add your code here


gs.addInfoMessage("Message which I wanted to appear on the form");



})(current, previous);


Megha Padale
Giga Guru

Hi,

You can use addInfoMessage() method of g_form API.

addInfoMessage(String message)

Adds an informational message to the top of the form.

Parameters:

NameTypeDescription
messageStringThe message to display.

 

If my answer helped you in any way, mark answer as helpful and correct.

Thanks and regards,

Megha.