Skip to content

Commit aca60f5

Browse files
Create HideDepnedentField.js
Client script to Hide the field if there are no dependent choices for parent field choice value
1 parent 22a2e4a commit aca60f5

File tree

1 file changed

+18
-0
lines changed
  • Client-Side Components/Client Scripts/Hide Dependent Choice field if there no dependent choices

1 file changed

+18
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
2+
var fieldToHide = 'subcategory'; // I have taken subcategory as an example
3+
if (newValue === '') {
4+
g_form.setDisplay(fieldToHide, false);
5+
return;
6+
}
7+
var ga = new GlideAjax('NumberOfDependentChoices');
8+
ga.addParam('sysparm_name', 'getCountOfDependentChoices');
9+
ga.addParam('sysparm_tableName', g_form.getTableName());
10+
ga.addParam('sysparm_element', fieldToHide);
11+
ga.addParam('sysparm_choiceName', newValue);
12+
ga.getXMLAnswer(callBack);
13+
14+
function callBack(answer) {
15+
g_form.setDisplay(fieldToHide, parseInt(answer) > 0 ? true : false);
16+
}
17+
18+
}

0 commit comments

Comments
 (0)