Skip to content

Commit 7a4e347

Browse files
authored
Dynamic reference qualifier with filtering (#2186)
* Create reference_qual_dynamic.js * Create README.md
1 parent ce2837f commit 7a4e347

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
**Dynamic Reference Qualifier with Filtering**
2+
This Client Script provides a solution for dynamically updating the available options in a Reference Field based on the value selected in another field on the same form.
3+
4+
This technique is essential for ensuring data quality and improving the user experience (UX).
5+
6+
A typical use case is filtering the Assignment Group field to show only groups relevant to the selected Service, Category, or Location.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
2+
if (isLoading || newValue === '') {
3+
return;
4+
}
5+
var controlledField = 'assignment_group';
6+
var controllingField = 'u_service';
7+
var serviceSysId = g_form.getValue(controllingField);
8+
var encodedQuery = 'typeLIKEITIL^u_related_service=' + serviceSysId;
9+
g_form.setQuery(controlledField, encodedQuery);
10+
var currentGroupSysId = g_form.getValue(controlledField);
11+
if (currentGroupSysId && oldValue !== '' && currentGroupSysId !== '') {
12+
g_form.setValue(controlledField, '');
13+
}
14+
}

0 commit comments

Comments
 (0)