- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-04-2020 05:48 AM
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
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-04-2020 05:56 AM
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
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-09-2020 05:55 AM
Hi All,
There is a way to pass variables to placeholders in the string within getMessage.
Use the withValues function on object returned by getMessage.
Please check the below code.
// Client script example:
function onLoad() {
// get preloaded message
var myMsg = getMessage("Logout"); // Logout
// get preloaded messsage and format
var myMsg = getMessage("The {0} says {1}!");
myMsg = myMsg.withValues(['cow', 'moo']); // The cow says moo!
// get message async
getMessage("Hello World", function(msg) { g_form.addInfoMessage(msg); } ); // Hello World
// get message async and format
getMessage("Good Morning, {0}!", function(msg) { g_form.addInfoMessage(msg.withValues([g_user.getFullName()])); } ); // Good Morning, Fred Luddy!
}
Regards,
Suraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-02-2025 08:40 AM
to use on the client side(on change) use below code -