I want to display a field message.

Taaha M
Tera Contributor

I want to display a field message and the message should be in the following format:

"The order placed is listed in your requests

Navigate to it"

But when i m using g_form.showFieldMsg() it is not helping me to go to new line.
How can I achieve this

1 ACCEPTED SOLUTION

SriharshaYe
Kilo Sage

showFieldMsg() in ServiceNow does not  support multi-line messages or HTML formatting like <br> tags or \n. if you want it to display  multi-line messages , you need to call g_form.showFieldMsg() multiple times. In the above case you need to call g_form.showFieldMsg()  2 times like

 g_form.showFieldMsg ('field_name', 'The order placed is listed in your requests', 'info'); 
g_form.showFieldMsg ('field_name', 'Navigate to it', 'info');

(or)

another approach is to use addInfoMessage() which supports multi-line messages , as it will allow you to use <br> for line breaks .

g_form.addInfoMessage('The order placed is listed in your requests<br>Navigate to it');

 

 

If my response is useful . click here to mark the posts as helpful.

View solution in original post

2 REPLIES 2

Nikhil Bajaj9
Giga Sage

Can you please describe what is your meaning by - "it is not helping me to go to new line."

Please appreciate my efforts, help and support extended to you by clicking on – “Accept as Solution”; button under my answer. It will motivate me to help others as well.
Regards,
Nikhil Bajaj

SriharshaYe
Kilo Sage

showFieldMsg() in ServiceNow does not  support multi-line messages or HTML formatting like <br> tags or \n. if you want it to display  multi-line messages , you need to call g_form.showFieldMsg() multiple times. In the above case you need to call g_form.showFieldMsg()  2 times like

 g_form.showFieldMsg ('field_name', 'The order placed is listed in your requests', 'info'); 
g_form.showFieldMsg ('field_name', 'Navigate to it', 'info');

(or)

another approach is to use addInfoMessage() which supports multi-line messages , as it will allow you to use <br> for line breaks .

g_form.addInfoMessage('The order placed is listed in your requests<br>Navigate to it');

 

 

If my response is useful . click here to mark the posts as helpful.