g_form.showFieldMsg not working

alex_tan
Kilo Contributor

Hi All,

I am encountering an issue now where g_form.showFieldMsg("field name","error message","error") is not loading error message in London Service Portal for a onChange Catalog Item client script.

Would like to seek advice on this issue.

Thanks a lot for your help!

28 REPLIES 28

This also applies when using g_form.setValue().  g_form.showFieldMsg() must come after the call to g_form.setValue() for the same field.

I was struggling with this issue and your suggestion worked perfectly.  

Thank you so much.

Just got caught out by this one and came across your post. Thanks very much.

Doug23
Tera Contributor

Just had this issue myself, found it wasn't working on a setValue/showFieldMsg of a reference field....

g_form.setValue('user', gr.assigned_to);
g_form.setFieldMsg('user','test message','info',false);

The above wouldn't work, but if I changed the field the setFieldMsg was pointing at, it worked fine

I believe the issue was that the g_form.setValue on a reference field does an implicit lookup to the value of the user to retrieve the DisplayValue of the record, triggering a second setValue, which in turn clears any field message (although someone please correct me if I'm wrong. Changed my code to:

var grUser = new GlideRecord('sys_user');
grUser.addQuery('sys_id', gr.assigned_to);
grUser.query(callbackFunction);

...



function callbackFunction(gr) {
  if (gr.next()) {
    g_form.setValue('user',gr.getValue('sys_id'), gr.getDisplayValue());
    g_form.showFieldMsg('user','Message here','info',false);
  }
}

This did the trick for me. Posting in the hopes it will help someone else (as this was the first googled result)

Subhojit Das
Kilo Guru

Hi,

Can you check whether the UI type is "Mobile/Service Portal"

find_real_file.png

Regards,

Subhojit Das