Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Need to make the variable section editable for one specific catalog in RITM

Sai1911
Tera Contributor

I need to make the variable section editable for a specific catalog item in RITM table. 

 And here's the script we are using: 

 

function onLoad(){
   try{
      //Get the 'Variables' section
      var ve = $('variable_map').up('table');
      //Disable all elements within with a class of 'cat_item_option'
      ve.select('.cat_item_option', '.slushselectmtm', '.questionsetreference', '.form-control', '.checkbox').each(function(elmt){
         elmt.disabled = true;
      });
      //Remove any reference or calendar icons
      ve.select('img[src*=reference_list.gifx]', 'img[src*=small_calendar.gifx]').each(function(img){
         img.hide();
      });
      //Hide list collector icons
      ve.select('img[src*=arrow]').each(function(img){
         img.up('table').hide();
      });
   }
 catch(e){}
   }
 
We can use the OOB script :
 
function onLoad() {
g_form.setVariablesReadOnly(true);
}
 
But this OOB script is hiding the multi row variable set in the RITM table. So we opted to use a customized script. So we can't use this script.
 
But now the requirement is we need to a edit the info in a specific catalog item in the RITM table and the rest has to be read only.
1 REPLY 1

mayankkumar
Kilo Patron
Kilo Patron

Hi @Sai1911,
------------------------------------------------------------------------------------------------------------------------------------------------------
You can just add a condition in your onLoad client script that ->

if(g_form.getValue('cat_item') === 'your cat_item sys_id'){
// your logic
}

Do let me know if you need further help
---------------------------------------------------------------------------------------------------------------------------------------------------
Please mark my response helpful and accept as solution
Thanks & Regards
Mayank