Edit button for case form

adam_cannon_23
Tera Contributor

I have created a Ui action to add a button to the CSM workspace case form.
The design is all fields will be read only when a case is opened (On display) and when I click the button "Edit" all fields then become editable excluding the "number" and "priority" fields. 

This is the script so far-

var fields = g_form.getReadOnlyFields();
        var len = fields.length;  
        for (var i = 0; i < len; i++) {  
            g_form.setReadOnly(fields[i], false);  
        }
        g_form.setReadOnly("Number",true);
        g_form.setReadOnly("priority",true);

Any further assistance to this setup would be appreciated
3 REPLIES 3

Amarjeet Pal
Kilo Sage
Kilo Sage

Hello @adam_cannon_23 ,

Your script to make fields editable while keeping certain fields as read-only looks correct. However, there are a few things to consider when adding this UI action to the CSM workspace.
1. Your script should be enclosed in a function and should be specified in the "Script" field of your UI action. Also, ensure that the "Client" checkbox is checked since you're executing client-side scripting.

2. In your 'Onclick' field, specify the name of your function so it gets executed when the button is clicked.

3. Define conditions

Example setup for your UI Action could look like:

  • Name: Edit Case
  • Table: Case
  • Form Button: Selected
  • Client: Selected
  • Onclick: editCase
  • Condition: !current.newRecord // This ensures 'Edit' button is not available while creating new records

And in the Script section:

function editCase() {
    var fields = g_form.getReadOnlyFields();
    var len = fields.length;  
    for (var i = 0; i < len; i++) {  
        g_form.setReadOnly(fields[i], false);  
    }
    g_form.setReadOnly("number",true);
    g_form.setReadOnly("priority",true);
}

Your onclick field is empty.

 

Thanks

Amarjeet Pal

Hi Amarjeet,

 

Thank you for your reply, it doesn't look like the button is working, nothing seems to trigger when it is pressed and when trying to use UI Action debug there doesn't look to be any useful information retrievable.

 

Adam C

adam_cannon_23
Tera Contributor

Hi Amarjeet,

 

We are unable to get this working, we have tried the above however the button does not look to trigger on click,

 

When testing none of the read-only fields change and the UI action debug doesn't help much

 

Kind Regards

 

Adam Cannon