getMessage on Service Portal

peterraeves
Mega Guru

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:

Image 8.png

Messages:

Image 99.png

When I click 'try it' on record producer, I get:

Image 5.png

When I go to portal, I get:

Image 6.png

With error message:

Image 7.png

9 REPLIES 9

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 😕


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

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

actually got it...thanks again for the great post!

getMessage('message key', function(msg){
alert(msg);
}

Ashutosh Munot1
Kilo Patron
Kilo Patron

https://community.servicenow.com/community?id=community_question&sys_id=27a1c260dbe9a744f0612183ca96199d