Need to make all the fields editable on a table after clicking the UI action button
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-15-2025 04:32 AM
Hello folks,
My requirement is, I have created a client script to make all fields on the form in read only state. Also I have created a UI action button which will only be seen on the table form to users having that particular role. When user clicks on the UI action button, I want all the form fields to be in editable state. How can I achieve that?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2025 05:40 AM
You probably cannot do this completely. Some fields will be visible and/or read only based on a UI Policy. You can't turn off a UI Policy from a UI Action, so the UI Action would only be able to change the read only attribute for fields it can see. If you have a specific list of fields you need to be editable, you can add a line for each one like the following.
g_form.setReadOnly(fieldname, false);
One way to kind of "hack" it would be for the UI Action to set a particular field on the form. Then you can create UI Policies such that if that field is set, then all the variables are editable. However, if that field is set, then anyone editing the record would see it as editable, which probably isn't the desired effect.
Another possibility would be to write into your UI Policies to leave the fields editable if the user has that particular role. Then people with that role would just always see the fields as editable.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2025 06:05 AM
Hi @PayalPawar ,
try this code
function onLoad() {
// Make all fields read-only initially
setAllFieldsReadOnly(true);
// Optional: Check if user has the role and show/hide button accordingly
if (g_user.hasRole('your_role_sys_id')) {
// Show the edit button (if hidden by default)
g_form.setDisplay('your_ui_action_sysid', true);
}
}
function setAllFieldsReadOnly(readOnly) {
var fields = g_form.getEditableFields();
for (var i = 0; i < fields.length; i++) {
g_form.setReadOnly(fields[i], readOnly);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2025 06:12 AM
but why?
what's your business requirement here?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader