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

@Sandeep kumar Jadhav 

Glad to know that my script worked.

Please mark my response as correct and close the question.

Regards
Ankur

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

Hi,

So in that UI policy add condition

Assignment Group [IS NOT] Group ABC

Regards
Ankur

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

Hi @Ankur Bawiskar 

 

But here the variables should be editable on RITM level. So when the logged in user is member of GROUP ABC, variables of that catalog item should be editable for the members of the logged in group

 

Thanks in advance

Hi,

okay group membership is required.

then that you cannot do using UI policy; remove that UI policy

Please use display BR on sc_req_item table

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

Then use onLoad client script on sc_req_item table

function onLoad(){

	// if not member then make variables readonly
	if(g_scratchpad.isMember.toString() == 'false')
		g_form.setVariablesReadOnly(true);
}

Regards
Ankur

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

Hi @Ankur Bawiskar 

 

This will break the script mentioned below. I am so sorry for the inconvenience but this is where I stuck

 

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); 
		}
	}); 

}

 

Thanks in advance