Create a toggle button
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2019 11:46 AM
We are attempting to create a UI Action button that toggles all fields to be editable on what they currently are set. We have the code:
var fields = g_form.getEditableFields();
for (var x = 0; x < fields.length; x++) {
g_form.setReadOnly(fields[x], true);
}
But what is the best method to reverse it? Create another UI Action that just undoes what was already done?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2019 12:01 PM
You could make another UI action. You could also make a hidden field that stores a true/false value. Use that as the toggle for the one UI action.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2019 12:21 PM
You can have a flag and have a function on button click checking the flag value and behave accordingly something like
on Click : setFields()
function setFields(){
if(flag){
var fields = g_form.getEditableFields();
for (var x = 0; x < fields.length; x++) {
g_form.setReadOnly(fields[x], true);
}
}
else{
var fields = g_form.getEditableFields();
for (var x = 0; x < fields.length; x++) {
g_form.setReadOnly(fields[x], false);
}
}}
Hope that helps
Mark the response as correct if that really helps
Thanks,
Siva