diff --git a/Client-Side Components/Client Scripts/Restrict Fields on Template/README.md b/Client-Side Components/Client Scripts/Restrict Fields on Template/README.md new file mode 100644 index 0000000000..6482017798 --- /dev/null +++ b/Client-Side Components/Client Scripts/Restrict Fields on Template/README.md @@ -0,0 +1,12 @@ +**Details** + +This is a on change client script on sys_template table. This script will restrict users to select defined fields while template creation. +Type: OnChange +Field: Template +Table: sys_template + +**Use Case** + +There is an OOB functionality to restrict fields using "**save as template**" ACL, but it has below limitations: +1. If the requirement is to restrcit more number of fields (example: 20), 20 ACLs will have to be created. +2. The ACls will have instance wide effect, this script will just restrict on client side. diff --git a/Client-Side Components/Client Scripts/Restrict Fields on Template/script.js b/Client-Side Components/Client Scripts/Restrict Fields on Template/script.js new file mode 100644 index 0000000000..625f432899 --- /dev/null +++ b/Client-Side Components/Client Scripts/Restrict Fields on Template/script.js @@ -0,0 +1,20 @@ +/* +Type: onChnage +Table: sys_template +Field: Template +*/ +function onChange(control, oldValue, newValue, isLoading, isTemplate) { + if (isLoading || newValue === '') { + return; + } + if (g_form.getValue('table') == 'incident') { // table on which sys_template is being created. + var fields = ['active', 'comments']; // array of fields to be restricted while template creation. + for (var i = 0; i < fields.length; i++) { + if (newValue.indexOf(fields[i]) > -1) { + alert("You Cannot Add " + fields[i]); // alert if user selects the restricted field. + var qry = newValue.split(fields[i]); + g_form.setValue('template', qry[0] + 'EQ'); // set the template value to previous values (oldValue does not work in this case). + } + } + } +}