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

In my case is it required to initiate array for I value? This is how I am trying now.



var cmArray=[];


var mcArray=[];


var glArray=[];



  cmArray.i = g_form.getValue(ccode);


  mcArray.i = g_form.getValue(mcode);


  glArray.i = g_form.getValue(glcode)





if (cmArray.i == '' || mcArray.i == '') {




if (glArray.i == '') {


alert(getMessage('Additional company {0}'),i);



}



}


Hi,



I am not sure if i has a value in your code. Did you try logging it? I suggest you replace it as glArray.i as this is where you are assigning the value



if (cmArray.i == '' || mcArray.i == '') {



if (glArray.i == '') {


alert(getMessage('Additional company {0}'),glArray.i);


}


}





Thanks


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


I tried   alert(getMessage('Additional company {0}'),glArray.i);


didn't worked. I may be doing something wrong.


Can you show me a screenshot of your message?



Your message should have



Key: Additional company


Message: Additional company {0}



Once you update it, just try the sample code and check if this works.



alert(getMessage('Additional company'),"My company");



Once you are able to setup alert, modify the other code.







Thanks


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


find_real_file.png


L_4A73.tmp.PNG


and the code is



  if (cmArray.i == '' || mcArray.i == '') {


if (glArray.i == '') {



alert(getMessage('Additional company'),"Kiran");



}



}