Make field readonly using UI Action

DevYadav
Tera Contributor

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!

9 REPLIES 9

AndersBGS
Tera Patron
Tera Patron

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/

Juhi Poddar
Kilo Patron

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

JuhiPoddar_0-1752327543510.png

  • Script:JuhiPoddar_1-1752327629741.png
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.

JuhiPoddar_2-1752327802994.png

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

venkat917181
Tera Expert

Step 1: Create the UI Action (Button)

  1. Navigate to System Definition > UI Actions
  2. 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);
}

Shubham_Jain
Mega Sage

@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


Anand Kumar P
Giga Patron
Giga Patron

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