Is there any server side function add or remove choices from dropdown instead of g_form.addOption or g_form.removeOption?

Hardeep Singh
Tera Contributor

The requirement is to add new subcategory on the basis of "assignment group=a" and "category=b" we should have "subcategory=ab" . Subcategory is dependent on category field. Using onChange client scripts gives partial solution not proper. So can I have any server side function to add or remove choices? 

Using 2 Onchange client scripts, one for Assignment group and another for Category but isn't working properly

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
   if (isLoading || newValue === '') {
      return;
   }
if(g_form.getValue("assignment_group")=="c6c828c453751300ba3dddeeff7b1219")
    {
        if(g_form.getValue("category")=="inquiry")
{
    g_form.addOption("subcategory","email","Email");
}}
    else{
        g_form.removeOption("subcategory","email","Email");
    }
    
   //Type appropriate comment here, and begin script below
}

1 REPLY 1

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

server side cannot add/remove options. It happens only on client side

If you are talking about incident form then subcategory is dependent on category so unless that category is there in option the subcategory won't be shown

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader