Skip to content

Commit 93e1dbb

Browse files
authored
Dynamic client script to make fields read only (#2415)
* Create script.js * Create reame.md
1 parent 011e42d commit 93e1dbb

File tree

2 files changed

+25
-0
lines changed
  • Client-Side Components/Client Scripts/Dynamic script to make fields read only

2 files changed

+25
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Dynamic script to make fields read only
2+
3+
It runs when the field value changes.On change client script
4+
If the new value equals '7', it retrieves all editable fields using g_form.getEditableFields().
5+
Then it loops through each field and sets it to read-only using g_form.setReadOnly().
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
It runs when the field value changes.
3+
If the new value equals '7', it retrieves all editable fields using g_form.getEditableFields().
4+
Then it loops through each field and sets it to read-only using g_form.setReadOnly().
5+
6+
*/
7+
8+
9+
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
10+
if (isLoading || newValue === '') {
11+
return;
12+
}
13+
14+
15+
if (newValue == '7') { // update condition as required
16+
var fields = g_form.getEditableFields();
17+
for (var i = 0; i < fields.length; i++) {
18+
g_form.setReadOnly(fields[i].getName(), true);
19+
}
20+

0 commit comments

Comments
 (0)