How to use getMessage("message key") in client script?

PhoenixMing0912
Giga Expert

Hi all,

I am using gs.getMessage() in business rule?

I am wondering how to use it in client script? I have tried g_form.getMessage(), but not working.

 

Regards,
Ming

1 ACCEPTED SOLUTION

Hi,

I believe the client side allows only 1 parameter; server side allows 2 parameters

check below links for help

Second Parameter of getMessage() on Client Side

gs.getMessage() - The Second Parameter

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

6 REPLIES 6

Ankur Bawiskar
Tera Patron
Tera Patron

@PhoenixMing0912 

it should be called like this in client script

getMessage("Your Message Key here", function(msg){
alert(msg); 
});

Output:

find_real_file.png

find_real_file.png

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Can I use second parameter as message varient?

Hi,

I believe the client side allows only 1 parameter; server side allows 2 parameters

check below links for help

Second Parameter of getMessage() on Client Side

gs.getMessage() - The Second Parameter

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Mark Roethof
Tera Patron
Tera Patron

Hi there,

You can just use the message field in combination with getMessage in Client Scripts and Catalog Client Scripts.

Do apply the message field! This preloads your message. If you don't do this, on initial load your message is not loaded.

If my answer helped you in any way, please then mark it as helpful.

Kind regards,
Mark
2020 ServiceNow Community MVP
2020 ServiceNow Developer MVP

---

LinkedIn
Community article list

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn