On Change Client Script to hide options ...

Zod
Giga Guru

Hi,

I need to remove options for a field - incase the field was changed to a certain value (NOT SUBMITTED).

Usually I would think an on change client script should do the job ... something like:

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

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

  return;

  }

  if (g_form.getValue('abc_status' == '900')) {

  g_form.removeOption('abc_status', 100);

  g_form.removeOption('abc_status', 200);

  }

  }

It doesn't work ... could anyone please tell me why?!

1 ACCEPTED SOLUTION

Gurpreet07
Mega Sage

condition should be


if (g_form.getValue('abc_status') == '900') {


View solution in original post

7 REPLIES 7

Goran WitchDoc
ServiceNow Employee
ServiceNow Employee

Saw you found your typo..  



but you can use console.log to log in the web browser or just put a alert("inside"); inside the if-statement and see if it pops up



//Göran


Gurpreet07
Mega Sage

condition should be


if (g_form.getValue('abc_status') == '900') {


vinothkumar
Tera Guru

Hi Vemffm,



I believe there was a mistake in this line of your code "   if (g_form.getValue('abc_status' == '900'))"



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


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


  return;


  }


//can you modify something as bellow and try it.


var x = g_form.getValue('abc_status');


  if (x == '900')) {  


  g_form.removeOption('abc_status', 100);


  g_form.removeOption('abc_status', 200);


  }


  }