How to create a set of dependent dropdown fields (Location, Building, Room) for a catalog request?
						
					
					
				
			
		
	
			
	
	
	
	
	
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
How do I create a set of dependent dropdown fields (Location, Building, Room) where the options in each subsequent field are filtered based on the selection in the preceding one, using a lookup select box variable type.
 
					
				
		
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Here's an example of how I have 2 lookup select box variables - Category and Subcategory - to mimic the incident out of box choice lists.
The Reference qualifier and Variable attributes of v_subcategory show how the dependency works
If your lookup tables are not sys_choice you would just update the reference qualifiers in a way that makes for your scenario.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @vzhang188 ,
Creating a set of dependent dropdown fields (Location, Building, Room) using a lookup select box variable type, where each subsequent field's options are filtered based on the preceding selection, typically involves the following steps:
Define your Data Source:
- Create a data source (e.g., a custom table, a database view) that contains the relationships between Location, Building, and Room. This data source should have columns for each level of the dependency.
- For example, a table could have columns like location_name, building_name, and room_number, with multiple rows for each location and its associated buildings and rooms.
Create the "Location" Lookup Select Box:
- Create a variable of type "Lookup Select Box" for "Location."
- Configure its "Lookup from table" to point to your data source.
- Set "Lookup value field" to the column containing the location names (e.g., location_name).
- Set "Lookup label field" to the same column (e.g., location_name).
Create the "Building" Lookup Select Box:
- Create another "Lookup Select Box" variable for "Building."
- Point its "Lookup from table" to your data source.
- Set "Lookup value field" to the column containing building names (e.g., building_name).
- Set "Lookup label field" to the same column (e.g., building_name).
- Crucially, add a "Reference qualifier" to this variable. This qualifier will filter the buildings based on the selected location. The qualifier would typically look something like this:
Code:
location_name={{location_variable_name}}
Replace location_variable_name with the actual name of your "Location" variable.
Create the "Room" Lookup Select Box:
- Create a third "Lookup Select Box" variable for "Room."
- Point its "Lookup from table" to your data source.
- Set "Lookup value field" to the column containing room numbers (e.g., room_number).
- Set "Lookup label field" to the same column (e.g., room_number).
- Add a "Reference qualifier" to this variable: to filter rooms based on both selected location and building:
Code:
location_name={{location_variable_name}}^building_name={{building_variable_name}}
Replace location_variable_name and building_variable_name with the actual names of your "Location" and "Building" variables.
Important Considerations:
Variable Names: Ensure the variable names used in the reference qualifiers exactly match the names of your lookup select box variables.
Data Consistency: The data in your source table must be consistent for the filtering to work correctly (e.g., building names should be consistently linked to their respective locations).
Performance: For very large datasets, optimize your data source and reference qualifiers to ensure good performance.
User Interface: The platform handling these variables (e.g., a service catalog in ServiceNow) will automatically refresh the options in dependent dropdowns when a selection is made in the preceding one.
If you found my response helpful, could you please mark it as ‘Accept as Solution’ and ‘Helpful’? This small action goes a long way in helping other community members find the right answers more easily and supports the community.
 
					
				
		
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
@NavinAgarwal - posting replies that are simply pasted from GenAI tools doesn't help anyone. We all know how to use ChatGPT, Copilot, etc. If it was that simple, we wouldn't need this forum.
