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

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


Geoffrey2
ServiceNow Employee
ServiceNow Employee

Nice.   I haven't seen this before.   Good to know.


I can't find any use of it in my instance, but I did find this: ServiceNow KB: The g_form.getControl method does not work after ordering (KB0547171)


Geoffrey2
ServiceNow Employee
ServiceNow Employee

Can you post the code?   It's hard to debug from our imaginations.


BALAJI40
Mega Sage

Hi,



  Just check, "applies on catalog task" is checked or not. If not then check the check box and see the result. Remove option will work.


find_real_file.png