Not working getmessage option in catalog client script

r_gissarl_
Mega Expert

Hello,

I'm having trouble to get working a showfieldmesage in a catalog client script. I need to show an alert when a user is selected. This part is ok, but I need the message to include the name of a field. I'm trying to use getmessage() with an option and this is not working.

There is the code of the catalog client script :

function onChange(control, oldValue, newValue, isLoading) {

      if (isLoading) {

              return;

      }

     

      if(newValue==''){

              g_form.hideFieldMsg('user_ref');

              return;

      }

     

      g_form.hideFieldMsg('user_ref');

     

      var selected = g_form.getReference('user_ref', setUserMessage);

     

      function setUserMessage(usr){      

             

              if(usr.u_pick_up_group!=""){

                      var pk = new GlideRecord('u_cmn_pick_up_group');

                      pk.get(usr.u_pick_up_group);

                      var msgg = getMessage("This user is already in {0} call pick up group, it will be deleted from the former one and associated with the selected one.",pk.u_name);

                      g_form.showFieldMsg("user_ref",msgg,"error");

                      }else{

                     

                      g_form.hideFieldMsg("user_ref");

              }

      }

}

This is the message stored in sys_ui_message :

key : This user is already in {0} call pick up group, it will be deleted from the former one and associated with the selected one.

message : This user is already in {0} call pick up group, it will be deleted from the former one and associated with the selected one.

The system only retuns : This user is already in {0} call pick up group, it will be deleted from the former one and associated with the selected one.

It didn't return the message with the value of pk.u_name instead of {0}. Do you have an idea to resolve this ?

1 ACCEPTED SOLUTION

Rushit Patel2
Tera Guru

Hi regis,



getMessage(String) on client side uses only one parameter vs gs.getMessage(String, Object) that can use a second parameter.




Thanks and Regards,


Rushit Patel


View solution in original post

3 REPLIES 3

Rushit Patel2
Tera Guru

Hi regis,



getMessage(String) on client side uses only one parameter vs gs.getMessage(String, Object) that can use a second parameter.




Thanks and Regards,


Rushit Patel


Rushit Patel2
Tera Guru

Hi regis,



u can directly build the message. why u are using getMessage.



for exp.


var msgg = "This user is already in "+ pk.u_name + "call pick up group, it will be deleted from the former one and associated with the selected


one.";



g_form.showFieldMsg("user_ref",msgg,"error");  



*****mark helpful/correct/like if it helps



Regards,


Rushit Patel


Hello Rushit,



I need a message to localize it depending the language of the connected user.



In your first message, this is probably why it doesn't work.