how to make read only variables on requested item

rakhi1234
Kilo Contributor

currently iam using the below script for making read only of available all variables on my requested item but now i want writable few of variables depends upon some conditon .how can i proceed this scenario can you please explain.

function onLoad() {

  //Type appropriate comment here, and begin script below

if(g_user.hasRole("itil"))

{

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').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){}

}

}

10 REPLIES 10

Shahed Shah1
Tera Guru

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Rakesh,



Have a catalog client script which applies to RITM view and as per your condition add following line of code


First make all fields readonly using below code and then add your condition to make few of the fields as non-readonly




g_form.setVariablesReadOnly(true);



if(condition is true){


// make fields you want as non-readonly one by one


}



Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.


Thanks


Ankur


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

If condition is true how to make it writable can you please help me


Actually my requirement is I have to create new field qualification   true/false the variable form if the qualification is true the variable is editable on requested item...otherwise read only


Kindly suggest how to achieve this