Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

system ui messages with dynamic variable

kdevireddy
Giga Contributor

Hi

I am trying to create a new system ui message with dynamic argument which needs to be translated

Here I am sharing how it's configured

alert(getMessage('Additional company'+i+'details' must be entered'));

and   have created entry in ui messages table - with key   'Additional company'+i+'details' must be entered' in English and French values. But alert is not getting values from message table.

Please help.

Thanks,

Kiran

1 ACCEPTED SOLUTION

Alikutty A
Tera Sage

Hi,



Here is how dynamic variables can be passed to messages



Single Parameter passing, Message sample "Incident {0} is created"



var msg = gs.getMessage('Incident {0} is created', current.number); // This is how you replace variable



Multiple parameter passing, Message sample "Incident {0} is updated to State: {1}"


                  var arr = [];


                  arr.push(current.number);


                  arr.push(current.state);


                  var msg = gs.getMessage('Incident {0} is updated to State: {1}', arr);



In your case. The message should be,   "Additional company {0} details must be entered" and you should replace this in your code



gs.getMessage('Additional company {0} details must be entered', i );


View solution in original post

17 REPLIES 17

Which are they? when you say gs, the glide system object is available to server side scripts.




Thanks


PS: Hit like, Helpful or Correct depending on the impact of the response


client script   - Verify Stock Available (Stockroom)



even there are others if you can search in scripts with *{0}.


They have used it in a different way, The second parameter is added on formatMessage function. Please try this out



alert(formatMessage(getMessage('Additional company'), 'Text'));








Thanks


PS: Hit like, Helpful or Correct depending on the impact of the response