Write ACL overwriting UI Policy

Ryax1
Tera Guru

Hi,

I have created a scoped application which does not extend any other table. I have created a read, write, create, and delete ACL to allow roles to perform these actions on records in the application.

I would now like make some of the fields read-only upon submission of a record, I have tried to do this via a Client Script using the below:

 

 

 

function onSubmit() {
g_form.setReadyOnly('short_description', true);
}

 

 

 

However the field doesn't get changed to read only, even if I change it to onLoad it does not work.

I then tried creating a UI Policy and found that the field briefly changes to read-only before quickly changing back to editable, making me think that it is the ACLs that are overwriting the field.

I have a table level write ACL that gives write access to all roles which I suspect is causing the issue however if I remove this then all of the fields become read-only/uneditable.

 

How can I make it so that my users still have access to all other fields but some are made read-only on submission?

1 ACCEPTED SOLUTION

Ryax1
Tera Guru

I found that this issue was being caused by a conflicting data policy that was overwriting the field being set to read-only. I have now addressed this and the above methods work correctly.

Thanks for everyone's help.

View solution in original post

7 REPLIES 7

Nayan  Dhamane
Kilo Sage
Kilo Sage

Hello @Ryax1 ,

You can use a onLoad Script with conditions,

if(g_form.isNewRecord){

g_form.setReadOnly('short_description',false); //please try setDisabled() if does not work.

}

else{

g_form.setReadOnly('short_description',true);

}



If my answer solved your issue, please mark my answer as Correct & Helpful based on the Impact

Best Regards,
Nayan Dhamane
ServiceNow Community Rising Star 2023.

Hi Nayan,

Thanks for your response. I've tried this with both setReadOnly and setDisabled but the field doesn't change. Would a write ACL take precedence over this Client Script causing it to not work?

Thanks

Richard

Ryax1
Tera Guru

I found that this issue was being caused by a conflicting data policy that was overwriting the field being set to read-only. I have now addressed this and the above methods work correctly.

Thanks for everyone's help.