ClientScript stopped working

manishc
Kilo Contributor

We have a client script which removes few options from a select box variable.

This used to work perfectly fine on my catalog item.

But today I exposed it to run on my fulfilment task form, and the same script is not working.

How do I make g_form.removeOption() work? If this will not work, how do I remove options from my select box.

Thanks

Manish

1 ACCEPTED SOLUTION

shouvik
ServiceNow Employee
ServiceNow Employee

Hi Manish



g_form.removeOption() is not a supported API for variables on Task Records.


Please refer to the documentation on the supported APIs



Client script access to variable fields on task records



For g_form APIs which you don't find working for Task Records, please use g_sc_form.


So g_sc_form.removeOption() would work. But you have the same CatalogClientScript which applies to catalog item and catalog task, have a check on g_sc_form.


Here is the code for the same



if (g_sc_form) {


  g_sc_form.removeOption()


}


else {


  g_form.removeOption()


}




Thanks


Shouvik


PS: Hit like, Helpful or Correct depending on the impact of the response


View solution in original post

6 REPLIES 6

Kalaiarasan Pus
Giga Sage

Change your script to this format to have the same script work on Catalog and Task level.



g_form.removeOption('variables.variablename') ;


g_form.removeOption('variables.variablename')


This is not working in Catalog Task level.



Thanks


Manish