Apply UI Policy on 'Variable Editor' field in Requested Item form [Self Service view]

cbender
Tera Contributor

Hello ServiceNow experts,

 

I have currently a problem with UI Policies in the requested item form.

 

I added 'Variable Editor' to selected fields in the requested item [Self Service view] form so that the user can see his requested items.

This works well BUT the user is able to change them.

So I want to make this 'field' read-only but ONLY for the user who ordered the item. (Info: in the workflow the 'Approval users' should have the possibility to change the variables).

So I tried to apply a UI Policy on the requested Item form but I could not locate the Table/UI Policy Action combination which solves the problem.

 

In Catalog UI Policies I am able to set each variable read-only. But this applies to every requested item form and not only to [Self Service view].

 

Could anybody give me a hint?

 

Thank you very much

7 REPLIES 7

marcguy
ServiceNow Employee
ServiceNow Employee

i've seen it done via client script before so you can be more granular about whom it's read only for:



Make Variables Read-Only After Checkout - ServiceNow Wiki


Brad Tilton
ServiceNow Employee
ServiceNow Employee

I've done something like this before with an onload client script on the request item form. Note that for this to work you need to have the requested for field shown on the ess view of the form. Otherwise you'll need to use getReference() or a display business rule.



function onLoad() {


  //assuming the requested for field is being shown on the item. if not you may have to use a display business rule of getreference


  var reqFor = g_form.getValue('request.requested_for');


  if (reqFor == g_user.userID) {


          //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();


          });


  }


}


This would work better as a view-specific client script instead of a global one. This way you wouldn't need to do the conditional check to see if the person looking at it is the person it's for. Set it up for ess view, drop the conditional, and it'll make everything RO for anyone viewing it in ess view.


cbender
Tera Contributor

Thank you for the hints.



We have noch defined a business rule where we copy all variables to the scratchpad and a client script where we set the variables which are stored in the scratchpad array, to read-only.