Catlong Client script reference field drop down info message

nani1
Tera Contributor

Hi All,

we do have a drop down reference field call "Area" in CatLog item.

under "Area" drop down values example 'A', 'B', 'C'.

I'm writing the on change CatLog client script to show the field msg based on the choice user selected: 

Script:

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

   if (isLoading || newValue == '') {

      return;

   }

   if (cat.Area == 'A')

   {

          g_form.showFieldMsg('Area''testing1');

   }

   else if (cat.Area == 'B')

   {

   g_form.showFieldMsg('Area','testing2');

   

   }

}

 

1 ACCEPTED SOLUTION

Weird
Mega Sage

There's no question here.
But if you're trying to get the value of a field on your form, then you'd have to use "g_form.getValue('field_name');
For example

 

  if (g_form.getValue('Area') == 'A') {
          g_form.showFieldMsg('Area', 'testing1');
   }

 

You can also use g_form.getDisplayValue to get the shown value. For example on incident table choices for state are numbers as values but text as the display value.

Also note that if your field is named "area" then in your script you need to use "area". Usually field names are in lower case while the labels might start with uppercase letter.

View solution in original post

1 REPLY 1

Weird
Mega Sage

There's no question here.
But if you're trying to get the value of a field on your form, then you'd have to use "g_form.getValue('field_name');
For example

 

  if (g_form.getValue('Area') == 'A') {
          g_form.showFieldMsg('Area', 'testing1');
   }

 

You can also use g_form.getDisplayValue to get the shown value. For example on incident table choices for state are numbers as values but text as the display value.

Also note that if your field is named "area" then in your script you need to use "area". Usually field names are in lower case while the labels might start with uppercase letter.