diff --git a/Client-Side Components/Client Scripts/Dynamic script to make fields read only/reame.md b/Client-Side Components/Client Scripts/Dynamic script to make fields read only/reame.md new file mode 100644 index 0000000000..ada42d5c30 --- /dev/null +++ b/Client-Side Components/Client Scripts/Dynamic script to make fields read only/reame.md @@ -0,0 +1,5 @@ +Dynamic script to make fields read only + +It runs when the field value changes.On change client script +If the new value equals '7', it retrieves all editable fields using g_form.getEditableFields(). +Then it loops through each field and sets it to read-only using g_form.setReadOnly(). diff --git a/Client-Side Components/Client Scripts/Dynamic script to make fields read only/script.js b/Client-Side Components/Client Scripts/Dynamic script to make fields read only/script.js new file mode 100644 index 0000000000..a685a9f35c --- /dev/null +++ b/Client-Side Components/Client Scripts/Dynamic script to make fields read only/script.js @@ -0,0 +1,20 @@ +/* +It runs when the field value changes. +If the new value equals '7', it retrieves all editable fields using g_form.getEditableFields(). +Then it loops through each field and sets it to read-only using g_form.setReadOnly(). + +*/ + + +function onChange(control, oldValue, newValue, isLoading, isTemplate) { + if (isLoading || newValue === '') { + return; + } + + + if (newValue == '7') { // update condition as required + var fields = g_form.getEditableFields(); + for (var i = 0; i < fields.length; i++) { + g_form.setReadOnly(fields[i].getName(), true); + } +