Make assignment group field read only on the incident form after saving in SOW

suryaogeti1
Tera Contributor

Once we select the assignment group and after saving the record in the incident form, the field needs to become read only in the service operations workspace, we can't change the assignment group. the below code is not giving the expected output. please help with this

 

function onLoad() {

 

    if (g_form.isNewRecord()) {
        g_form.setReadOnly('assignment_group', false);
        return;
    }

 

   
    var assignmentGroup = g_form.getValue('assignment_group');

 

    if (assignmentGroup) {
        
        g_form.setReadOnly('assignment_group', true);
    } else {
        g_form.setReadOnly('assignment_group', false);
    }

 

 
    g_form.setReadOnly('assigned_to', false);
}
7 REPLIES 7

Ankur Bawiskar
Tera Patron

@suryaogeti1 

why to raise this as duplicate question?

you already have open question

Make assignment field mandatory on the incident form after saving (SOW) 

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader

Sachin_Nasa
Tera Guru

Hi @suryaogeti1 ,

Your script is not working because Service Operations Workspace does not fully support classic onLoad client scripts and the form does not reload after save.

Correct way: Use a UI Policy (works in Workspace)

UI Policies are fully supported in Service Operations Workspace and are the recommended solution.

What to do (UI Policy specifications)

1. Create a UI Policy

  • Table: Incident
  • Applies to: All
  • Global: true

2. UI Policy Condition

  • Assignment group is not empty
  • New record is false

3. UI Policy Action

  • Field: Assignment group
  • Read only: true

That’s it.

 The assignment group becomes read‑only immediately after save
 Works in Service Operations Workspace and Classic UI
 No scripting needed

If you found this helpful, please mark it as Helpful and Accept as Solution so it can reach others too.

Thanks & Regards,
Sachin Narayanasamy

suryaogeti1
Tera Contributor

I have used Ui policies, if we select the assignment group, it is making read only, after saving the record, it is coming to normal state and it is editable. even after the saving the record, I need assignment group field to be read only by that no one can change the value

Tanushree Maiti
Kilo Patron

Hi @suryaogeti1 

 

  1. Navigate to Incident > All and open an incident.
  2. Right-click the form header and select Configure > UI Policies.
  3. Click New.
  4. Fill in the form:
    • Short Description: Read-only Assignment Group after save.
    • Table: incident
    • Conditions:  [Assignment group] [is not empty] AND [State] [is not] [New] 
    • Global: Checked.
    • Workspace: Checked (ensure this is enabled for SOW).
  5. Save the UI Policy.
  6. UI Policy Actions:
    • In the UI Policy Actions related list, click New.
    • Field name: assignment_group
    • Read only: True
    • Click Submit. 

 

Please mark this response as Helpful & Accept it as solution if it assisted you with your question.
Regards
Tanushree Maiti
ServiceNow Technical Architect
Linkedin: