Make field readonly using UI Action
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2025 08:47 AM
Hi Community,
I’m trying to add a button on the Incident table form that, when clicked, should make the State and Short Description fields read-only. Could anyone guide me on how to achieve this?
Thanks in advance!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-12-2025 04:57 AM
Hi @DevYadav ,
Why? Please share the business reason as it doesn't make any sense.
If my answer has helped with your question, please mark my answer as the accepted solution and give a thumbs up.
Best regards
Anders
Rising star 2024
MVP 2025
linkedIn: https://www.linkedin.com/in/andersskovbjerg/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-12-2025 06:49 AM
Hello @DevYadav
You can meet this requirement by following the below steps:
Create a UI Action on the Incident table with the following setup:
Action Type: Form Button
Client: True
- Script:
function makeFieldsReadOnly() {
g_form.setReadOnly('state', true);
g_form.setReadOnly('short_description', true);
}
Result:
Once the button is clicked, the State and Short Description fields will become read-only on the form.
Hope this helps!
"If you found my answer helpful, please like and mark it as an "accepted solution". It helps future readers to locate the solution easily and supports the community!"
Thank You
Juhi Poddar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-12-2025 06:56 PM
Step 1: Create the UI Action (Button)
- Navigate to System Definition > UI Actions
- Click New and configure:
- Name: Lock Fields (or your preferred name)
- Table: Incident [incident]
- Action name: lock_fields
- Form button: true
- Show insert: false (if you only want it on existing records)
- Onclick: lockIncidentFields();
Step 2: Create the Client Script Function
Add this script to the UI Action or create a separate client script:
function lockIncidentFields() { // Make State field read-only g_form.setReadOnly('state', true); // Make Short Description field read-only g_form.setReadOnly('short_description', true); // Optional: Show confirmation message g_form.addInfoMessage('State and Short Description fields are now read-only'); // Optional: Hide the button after clicking to prevent multiple clicks g_form.setDisplay('lock_fields', false); }
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-13-2025 12:40 AM
@DevYadav add below client script in UI Action
function lockFields() {
g_form.setReadOnly('state', true);
g_form.setReadOnly('short_description', true);
}
✔️ If this solves your issue, please mark it as Correct.
✔️ If you found it helpful, please mark it as Helpful.
—
Shubham Jain
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-13-2025 02:09 AM
Hi @DevYadav ,
Type UI Actions in the left navigation—Click New.
Name: Make Fields Read-Only
Table: Incident
Check: Active,Form button,Client, Show update,Show insert
on click: onClickReadonly()
In script section paste below script:
function onClickReadonly() {
g_form.setReadOnly('state', true);
g_form.setReadOnly('short_description', true);
}
If my response helped, please mark it as the accepted solution ✅ and give a thumbs up👍.
Thanks,
Anand