The CreatorCon Call for Content is officially open! Get started here.

disable choice list options

sigmachiuta
Kilo Guru

Is there a way to disable choice list options based off a query.   I have seen this Removing or Disabling Choice List Options - ServiceNow Guru

but what if my 'choice list' is actually a reference field and based on a previous user answer I wan to be able to remove certain choices from the reference.

4 REPLIES 4

Brad Tilton
ServiceNow Employee
ServiceNow Employee

For a reference field you should be able to use a reference qualifier to do that.



Reference Qualifiers - ServiceNow Wiki


I guess its a little more complicated than that.   What I am trying to do is have a reference qualifier that when a user is selected goes out to the user table and looks to see if any one of 4 conditions are meet (Boolean fields) and if they are an a record producer only show certain choices.   So I am thinking that I need to build a script include to query the user table and if those conditions are meet show them specific options..?


Yep you should be able to use an advanced reference qualifier with a script include to evaluate more complex conditions.


I am not sure if I am on the right track here.   I am trying to search the user table and if some values are true I need to look up in a new table where the u_c_level value is true and only return those records.   I am not sure how to look up the records and only return the ones needed..   Glide query to the table ? and how would i return the result to the list.



var GetUserAttributeAjax = Class.create();


GetUserAttributeAjax.prototype = {


      initialize: function(GetUserAttributeAjax) {




  var usr=current.variables.usrName;


  var gr = new GlideRecord('sys_user');


  gr.addQuery('user_name',usr);


  gr.query();


  if (usr.u_ceo == true || usr.u_cfo== true ){


  //return records to choice list from u_group table where u_c_level = true



  }


 


  else { //return other records where u_c_level false


      }


 


      },