making variables read only using ACL

pmelmoth
Kilo Contributor

Hi

I thought this should be a straight forward question but I haven't been able to find a decent answer.

We have variables inherited from the Catalog Item visible on the Request Item. Some of those are read-only others are not. This is controlled through Catalog UI Policies.

The thing is, they should be all set to Read Only when the RITM is set to active=false as a blanket rule.

I would expect to do this via ACL but the following rule does not work.

Operation: write

Name: sc_req_item.variables

Condition: active=true

Instead I tried this in an onLoad client script:

if (g_form.getValue('state') >= 3)

  g_form.setVariablesReadOnly(true);

That works fine but surely there is a better way.

Any advice?

Cheers

6 REPLIES 6

Ivano B
ServiceNow Employee
ServiceNow Employee

Hi Philip



There are a couple of fields on variables usually not visible on the variable form.


The first one is named 'write roles' and another 'read roles'.


If you select a role for the write roles you will see the variable locked directly if the user hasn't that role.



Of course the annoying thing is you have to look all the variables...



I hope this help


Cheers


Robo


pmelmoth
Kilo Contributor

Hi



No, I don't want to lock it down based on what role the user has.


I want to lock it down based on whether the ticket is active or not.


ghsrikanth
Tera Guru

The issue with the script that you have written is ACL is a server side script, but you have written g_form, which is only available in client side.


Hence it didn't work.


The catalog UI policy will propagate to the requested item but the fields which are editable in catalog item will be editable even in requested item.


For this I did DOM manipulation,


Please right click and Inspect element which you want to make it editable.


And write an onLoad script-



function onLoad(){


document.getElementId("ni.QSe3462fdd6f916100160ef92aea3ee4f4").disabled = true;


}



Mark if it is helpful or correct, feedback is appreciated


Hi



The first portion of code is the details of the ACL that did not work.



The second section of code is the same thing in a client script, which does work.



The issue is that I want to use an ACL if possible. I don't want to use a client script.


If not possible then OK, but there is the ability to set up ACL named "sc_req_item.variables" so I'm trying to ask if anyone knows how to do it considering it's not working for me.