Set Variables readonly on RITM

Sandeep kumar J
Tera Contributor

Hi Community

I need help for the below requirement

I want to make the variables read-only on the RITM form. I wrote a UI policy on the RITM table please find it below

find_real_file.png

This is working, but I have some variables for which the "Name" starts with "Edit_" should be editble on the RITM.

I have tried the below code, but it is not working

g_form.setReadOnly('variables.nameLIKEEdit^active=true','false');

Can you please help me if there is a way to fix this

 

Thanks in advance

22 REPLIES 22

Hi,

so you are using the above normal client script.

Then you can use display business rule and update your script as this

Please use display BR on sc_req_item table

g_scratchpad.isMember = gs.getUser().isMemberOf('Group ABC');

client script

function onLoad() {

    if(g_scratchpad.isMember.toString() == 'false'){
        $("variable_map").querySelectorAll("item").forEach(function(item){
            var variable = item.getAttribute("qname");
            if(!variable.startsWith('edit')){
                // if not starts with edit then make those readonly
                g_form.setReadOnly("variables."+ variable, true);
            }
        });
    }
}

Regards
Ankur

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

Changej Khan
Kilo Guru

Hi Sandeep,

 

You can achieve this requirement through configuration only.

1. In UI policy set condition if Name is not Edit

2. Write UI action to set the field read only.

 

Hi Changej khan

 

I have tried for the 1st point what you have mentioned.

 

But whatever the UI policy I wrote on sc_req_item table I was not able to select Variable.name on the condition of the UI policy