diff --git a/Client-Side Components/Catalog Client Script/Mandatory Subcategory based on Category/README.md b/Client-Side Components/Catalog Client Script/Mandatory Subcategory based on Category/README.md new file mode 100644 index 0000000000..ff62b69127 --- /dev/null +++ b/Client-Side Components/Catalog Client Script/Mandatory Subcategory based on Category/README.md @@ -0,0 +1,14 @@ +Client Script: Make Subcategory Mandatory Based on Category + +Overview: +This client script ensures that the Subcategory field becomes mandatory when a Category is selected on the Incident form. + +Implementation Details: + +Create a new Client Script with the following configuration: + +Type: OnChange +Table: incident +Field: category + +Add the provided script in the file mandatory_subcategory.js. diff --git a/Client-Side Components/Catalog Client Script/Mandatory Subcategory based on Category/mandatory_subcategory.js b/Client-Side Components/Catalog Client Script/Mandatory Subcategory based on Category/mandatory_subcategory.js new file mode 100644 index 0000000000..094b966be3 --- /dev/null +++ b/Client-Side Components/Catalog Client Script/Mandatory Subcategory based on Category/mandatory_subcategory.js @@ -0,0 +1,17 @@ +// Type: onChange +// Table: incident +// Field: category +function onChange(control, oldValue, newValue, isLoading) { + if (isLoading || newValue == '') { + return; + } + + // Make subcategory mandatory when category is selected + if (newValue=="") { + g_form.setMandatory('subcategory', true); + g_form.showFieldMsg('subcategory', 'Please select a subcategory', 'info'); + } else { + g_form.setMandatory('subcategory', false); + g_form.hideFieldMsg('subcategory'); + } +}