How to set all variables read only on RITM

Bhaskar24
Tera Expert

Hi All,

I want to set all the variables (ex: IT Onboarding Ticket etc..) read-only only on the RITM (not on Catalog Item) if the item: "Employee Requirements" and Assignment group is not "NAR CIB Onboarding" (please see below snippet)

find_real_file.png

Could you please help me!

Thanks & Regards,

Bhaskar

1 ACCEPTED SOLUTION

Hi Bhaskar,



If you want to restrict this behavior only for one item,you can write the above script on Employee Requirements item in Catalog client script instead of Requested Items Table and you can set a condition as



function onLoad() {



if(assignment_group!='NAR CIB Onboarding')


{


  g_form.setVariablesReadOnly(true);


}


}


View solution in original post

13 REPLIES 13

chirag_bagdai
ServiceNow Employee
ServiceNow Employee

Hi Bhaskar,



Can you please try "g_form.setVariablesReadOnly(true)" in onLoad client and see if that works.


Hi Chirag,



I want to set read-only the variables if item: "Employee Requirements" and Assignment group is not "NAR CIB Onboarding" only.


Could you please help!



Thanks & Regards,


Bhaskar


harishdasari
Tera Guru

Hi Bhaskar,



Create Catalog UI policy,



"Applies on Requested Items" should be checked.  



In when to apply don't give any condition.



Don't use client script, it is not best practice to use client script for read-only



find_real_file.png




thanks



This might be helpful.


thank you so much

Kusuma2
Kilo Guru

Hi Bhaskar Reddy



As per you requirement : I would like to know where do you have assignment group field is present.


To make all the variables read only for particular item write the catalog client script for that particular.


Here is the script:



function onLoad() {


$(variable_map).select("item").each(function (elmt){


  try {


    g_form.setDisabled('variables.' + elmt.getAttribute('qname'),true);


  } catch (err) {


  }


});


}



Hit correct/helpful based on impact.


Regards


Ajay