removing options in a dropdown

scottjus82
Kilo Guru

Hey all,

I cant work out why my scripts are not working. i need to do this this on two different tables/locations

1. Catalog item. I need to remove an option dependent on the answer to the previous question. my script is below, I have changed this several times but cant work out what is wong with my script. I guess the first question is can this be done on a catalog item?

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

      if (isLoading) {

            return;

  }

    var ecms_mob = g_form.getValue('ecms_mobile');

    if (ecms_mob =='No'){

          g_form.removeOption('device_type', 'Smartphone');

    }

}

2. Removing resolved as an option based on an incident being a new ticket.

function onLoad() {

    if (g_form.isNewRecord())

          g_form.removeOption("state", 6);

}

I have been going around in circles on these, if someone could point out the problem it would be most appreciated.

Thanks

11 REPLIES 11

So, we are almost there! thanks so much,



The only thing i know they will complain about is when smartphone is remove


its replaced with -none- which is already included (and has to be) so i now


get



-none-


-none-


Tablet


Laptop



Any thoughts?



On 9 March 2017 at 20:40, mallen_nspi <community-no-reply@servicenow.com>


maybe its a cache thing?



dont forget the else part to addoption...



http://wiki.servicenow.com/index.php?title=GlideForm_(g_form)#addOption