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,

then you need to do this

1) normal client script on sc_req_item table

Ensure this

1) Isolate Script field is set to false on this client script

2) if this field is not on form then from list you can make it false

This will make all variables readonly except those whose name starts with edit

example: edit_user, edit_group etc

function onLoad() {

	$("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); 
		}
	}); 

}

find_real_file.png

Regards
Ankur

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

Hi @Ankur Bawiskar 

 

I have tried the above mentioned script, but it is not working. And I came to know that SetReadOnly API is not working on the current versions of Servicenow.

Is there any other way to fix this ?

 

I have tried the API mentioned below

g_form.setVariablesReadOnly(true);

Still its not working

Hi,

this script should work fine in normal client script on sc_req_item table

g_form.setVariablesReadOnly(true);

Regards
Ankur

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

Hi @Ankur Bawiskar 

 

This is working now

 

But I have a catalog item for which the variables should be editable only for a particular group. The client mentioned above is setting all the variables readonly- but I made them editable through catalog UI policy, but they are editable to everyone.

I want all the varaibles of that catalog item editable on the RITM level only for that particular group.

 

Any suggestion on this ?

 

Thanks in advance

Sandeep