Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

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

Maik Skoddow
Tera Patron
Tera Patron

Hi @Ryax1 

use

g_form.setDisabled('short_description', true);

Maik

Hi Maik,

I tried changing g_form.setReadOnly to g_form.setDisabled but nothing changes. I think it must be ACL related.

Rich

Sunny15
Tera Guru

Hello @Ryax1 ,

 

There is spelling mistake in code its should 'setReadyOnly', kindly use on load script with following code.

 

function onLoad() {
   //Type appropriate comment here, and begin script below
	g_form.setReadOnly('short_description',true);
   
}

 

Hi Sunny,

Apologies I think that must've been a typo when I created the community post. I double checked the code in my instance and it is set to 'setReadOnly'.

Thanks

Rich