getMessage on Service Portal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-25-2017 06:23 AM
For some reason SN stopped supporting the getMessage function on the mobile or SP interface... So what's the equivalent to do this? They must have some function to do some translations on SP in client scripts, right?
Client script on record producer:
Messages:
When I click 'try it' on record producer, I get:
When I go to portal, I get:
With error message:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-25-2017 08:14 AM
Though, I'm not completely there I noticed something else.
Server side you can do:
gs.getMessage('Message {0}', [firstvalue])
and it will put the firstvalue in the place of the {0}.
Does anyone know how to do that client side? I tried
getMessage('Message {0}', [firstvalue], function(msg){})
and
getMessage('Message {0}', function(msg){}, [firstvalue])
But both did not work 😕
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-22-2018 09:27 AM
Per this community post the second parameter with the getMessage and interpolation (maybe that's not the right word for {0}) doesn't work client-side.
https://community.servicenow.com/community?id=community_question&sys_id=fbb3c3a5dbd8dbc01dcaf3231f9619b7
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-31-2018 12:32 AM
great post and solution...but is there a way to get this to work for an alert()?
I'm trying to use getMessage for an alert() on an onSubmit client script on a record producer for enforcing attachments.
this is what I've done following your solution, but the script blows up. Any idea how this can work for an alert?
alert(getMessage('DP - survey target employees in germany - yes'), function(msg));//not working...the function(msg) does not work in this context
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-31-2018 12:58 AM
actually got it...thanks again for the great post!
getMessage('message key', function(msg){
alert(msg);
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-31-2018 01:44 AM
https://community.servicenow.com/community?id=community_question&sys_id=27a1c260dbe9a744f0612183ca96199d