Dynamic Subcategory Dropdown Population in ServiceNow Workspace Based on Service Offering

fasiham13180808
Tera Contributor

In ServiceNow Workspace (SOW), I want to populate the Subcategory field dynamically based on selected Service Offering using Script Include.

The Script Include returns a list of allowed subcategories.

My issue is:

  • g_form.addOption() / removeOption() is not supported in Workspace
  • I am not able to filter dropdown options

What is the correct or recommended way to dynamically populate or filter dropdown values in Workspace?

3 REPLIES 3

Naveen20
ServiceNow Employee
 g_form.addOption(), removeOption(), and clearOptions() are not reliably supported in Now Experience workspaces The component re-renders choice fields from the data layer, overriding client-side option changes.

Recommended: dependent choice field

1. Open the sys_dictionary entry for the subcategory field.
2. On the Dependent Field tab, check Use dependent field and set Dependent on field = service_offering.
3. On each sys_choice record for subcategory, set the Dependent value to the matching service_offering value.

This is platform-native and works in Workspace, classic UI, and Service Portal — no client script or Script Include needed.

Caveats
- OOTB subcategory on task is already dependent on category. Repointing it to service_offering changes existing behavior
- If the mapping is many-to-many or driven by a custom table, convert Subcategory to a reference field and apply a reference qualifier (advanced/dynamic, calling your Script Include). Reference qualifiers are fully supported in Workspace.

Hi @Naveen20,

We have a dependency on two fields: Category and Service Offering.

In the Category field, we have two values, and for each value there is a separate table where the Subcategory choice field and the Service Offering reference field are mapped. That is the issue here.

For example, one Service Offering can have 5 mapped choices (5 records).

Naveen20
ServiceNow Employee

Supported pattern for a many‑to‑many mapping driven by a custom table is to convert Subcategory from a choice field to a reference field pointing at your mapping table, then filter it with an advanced (dynamic) reference qualifier that calls your Script Include. Reference qualifiers are evaluated server‑side and work consistently in SOW, classic UI, and Portal.
Steps

Consolidate the two category-specific mapping tables into one (or a single view) with columns: category, service_offering, and subcategory (label/value). Two tables will force branching logic everywhere.
Change the Subcategory dictionary entry to type reference → that mapping table.
On the dictionary entry, set Reference qual = Advanced and use:


javascript: new SubcategoryFilter().getQuery(current.category, current.service_offering)


Script Include (client‑callable not required for ref qual):

var SubcategoryFilter = Class.create();
SubcategoryFilter.prototype = {
initialize: function() {},
getQuery: function(category, serviceOffering) {
return 'category=' + category + '^service_offering=' + serviceOffering;
},
type: 'SubcategoryFilter'
};

Set the form so Subcategory’s value clears when Category or Service Offering changes (UI policy or onChange g_form.setValue('subcategory','')).

If converting the field type isn’t acceptable, the only remaining supported route in Workspace is a Decision Table or server‑side validation Business Rule — there is no reliable client API to mutate choice options in Now Experience.