Show field message not working properly

rafaelalves4337
Tera Contributor

Hello team,

 

I'm finishing a catalog form and got stucked with a "simple" thing.

 

The form has 2 options, Deactivate and Re-Activate groups, if the user types a group name that is already activate and select (Re-Activate), it must show a message saying that the group is already active in service now, it's working but not very well.

 

To make the message show, I need to change the selection of Deactivate and Re-Activate 2 times, if I just type the group name and select 1 option, it is not showing the message.

 

Note: I created a hidden variable called group_status that auto populate true or false depending on the group name.

 

My Client Script

function onChange(control, oldValue, newValue, isLoading) {
   if (isLoading || newValue == '') {
      return;
   }


g_form.hideFieldMsg('group_status'); //hide any previous messages

if (newValue == 'reactivate'&& g_form.getValue('group_status') == 'true') {
    g_form.showFieldMsg('name_of_the_group_2','This group is already ACTIVE in Service Now','info');
}

if (newValue == 'deactivate' && g_form.getValue('group_status') == 'false') {
    g_form.showFieldMsg('name_of_the_group_2','This group is already INACTIVE in Service Now','info', true);
}
}

Screenshot_178.jpgScreenshot_177.jpg

1 REPLY 1

Gangadhar Ravi
Giga Sage
Giga Sage

Bring the field on the form display and hide it using g_form.setDisplay

 

Then you will be able to read it as its present on the form. if its not in the layout itself then you will have to read it from server side and will have to make an ajax call for it, long way.