how to make field read only on a particular condition through data policy ?

Venky Kshatriy2
Tera Contributor

how to make field read only on a particular condition through data policy  which are already mandatory through data policy.!!

4 REPLIES 4

Roshan Tiwari
Tera Guru

Hi @Venky Kshatriy2 ,

 

If fields are set to mandatory, then read only and visible condition couldn't be applied, you try first fill the value and then try to make that readonly. 

 

OR if you want to make read only then make mandatory = false.

AndersBGS
Tera Patron
Tera Patron

Hi @Venky Kshatriy2 ,

 

You should look into the UI Policy which can ensure your requirement. Pay close attention to the order of those UI policies attached to the fields,  The order of evaluation is from the lowest number to the highest number (ascending order). 

 

If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.

 

Best regards

Anders

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/

Rajesh_Singh
Kilo Sage
Kilo Sage

@Venky Kshatriy2 

 

you can make a field read-only under certain conditions using a combination of a UI Policy and a Data Policy.

Here's how you can set up a UI Policy to make a field read-only based on a condition:

  1. Navigate to System UI > UI Policies in your ServiceNow instance.

  2. Click "New" to create a new UI Policy.

  3. Fill out the form with the following information:

    • Name: A descriptive name for the UI Policy.
    • Table: Select the table where the field you want to make read-only is located (e.g., sn_grc_policy).
    • Active: Ensure the "Active" checkbox is selected.
    • Short description: Add a brief description of the UI Policy.
    • Condition (Optional): Define the condition under which the field should be made read-only. Leave this empty if you want the field to be read-only under all circumstances.
  4. Click "Submit" to save the UI Policy.

  5. Now, add a UI Policy Action to define the read-only behavior for the field. In the "UI Policy Actions" related list, click "New."

  6. Fill out the form with the following information:

    • UI Policy: The name of the UI Policy you created earlier.
    • Type: Select "Read Only" from the dropdown.
    • Field name: Select the field you want to make read-only (e.g., short_description).
    • Reverse if false: If the condition is not met, the field will be editable. Check this box if you've set a condition in the UI Policy.
  7. Click "Submit" to save the UI Policy Action.

Now, you have a UI Policy that makes the field read-only based on the condition you've specified. However, since you mentioned that the field is already mandatory through a Data Policy, you need to ensure that the Data Policy doesn't interfere with the read-only behavior.

To address this, update the Data Policy to include the same condition you used in the UI Policy, so the field is only mandatory when it's editable:

  1. Navigate to System Policy > Data Policies in your ServiceNow instance.

  2. Locate and open the Data Policy that makes the field mandatory.

  3. Update the "Condition" field to match the condition you used in the UI Policy. If you didn't set a condition in the UI Policy, you may need to create a new Data Policy with a condition that complements the UI Policy.

  4. Click "Update" to save your changes.

By following these steps, you can create a setup where the field is mandatory and read-only based on specific conditions, without conflicts between UI Policies and Data Policies.

If you found my response helpful or applicable, please consider marking it as correct or helpful to assist others who may be seeking the same information.

---------------
Regards,
Rajesh Singh

Community Alums
Not applicable

Hi @Venky Kshatriy2 ,

I agree with @Roshan Tiwari , as you cannot make a field readonly if it's mamdatory, else you cannot submit/update/save the record.

So, first review the Data Policy and set the mandatory condition as false in the data policy and then you can apply a UI policy to make the field Read Only.