Multiple Choice Variable with Reference Qualifier

TrenaFritsche
Tera Expert


Hi All,

I am having a problem with a Catalog form that has a multiple choice variable.   The choices for the variable are coming from the pc_hardware_cat_item table and I have the following reference qualifier on it: javascript:wmc_filter_options()...this function looks like this:

function wmc_filter_options() {

      var myTable = current.getTableName();
      var string = "";
      gs.addInfoMessage('Filtering the List ');
      gs.addInfoMessage('myTable ' + myTable);

      if (myTable == 'sc_cat_item') {
            var printerColor = current.variables.newprt_color;
            var printerType =   current.variables.newprt_printerType;

            gs.addInfoMessage('printerColor ' + printerColor);            

      string = "category=604e09e26069210055dd239fccf49a07^u_print_color=" + current.variables.newprt_color + "^u_printer_type="   + current.variables.newprt_printerType + "^u_ihis_print="   + current.variables.newprt_IHIS + "^u_prescription_print="   + current.variables.newprt_Prescriptions + "^u_sheet_count="   + current.variables.newprt_SheetsPrinted + "^u_user_number="   + current.variables.newprt_NumberUsers + "^u_double_sided_printing="   + current.variables.newprt_DoubleSided;

      gs.addInfoMessage('string ' + string);
      return string;
    }
}

On the Catalog Item, I have the choice variables that are to be selected by the user and I am wanting the reference qualifier on the multiple choice variable to use the selected values but the problem is the reference qualifier is not using the variable values that are being selected, it is using the variables default values that they are initially set to upon loading of the form.   I cannot query a table because the values have not been save to any table until it gets submitted, but I need to limit the choices that display for selection based upon questions that the user answers (variables on the form)   I was trying to figure out how to control when the reference qualifier would execute and run the script?   Does anyone know how I can get this to work?   Please help if you can.   If you need any additonal information, please ask.

Thanks,
Trena

1 ACCEPTED SOLUTION

Hi Lars,


I wasn't able to use radio buttons because it wouldn't allow me to add or remove options but a , I did end up using a Lookup Select Box and basically used a GlideAjax Function from Client Script to send the variable parameters to a server script include to load the values in an array and return the possible options back to the the Client as an array and did a g_form.addOption on the Lookup Select Box variable.   This worked fine, although I did have to trade the look that I wanted, but the end results works great.   Now if the Multiple Choice field could somehow function that way.   I have other postings about the usagae of the GlideAjax that drove me to this solution, so you could probably search for that and see the details.   *Search for Query Catalog Item Variable



Thanks,


Trena


View solution in original post

6 REPLIES 6

manikorada
ServiceNow Employee
ServiceNow Employee

Trena,



In the Cases like this, its better to use Reference field. Which field you are using?


I guess I'm not sure what you mean?   The field is not a field but is a "variable" defined as a "Lookup Multiple Choice" type and the Lookup from table is pc_hardware_cat_item and the Lookup value field is "short description". It also has a Reference qual: field that has that javascript:wmc_filter_options() function call.   For some reason this function executes on load of the form that has this variable so I am looking to figure out how to cause this reference qual to execute after values are selected on the form...this function would use those variable values on the form to return a string that would qualify the values shown.



I hope this makes sense to everyone.



Thanks,


Trena


Trena,



If you are using Lookup Select Box, the reference qualifier only applies on the load of the form. Thats the reason you need to use variable of type reference in this case, because for the variable of type reference to select you will use magnifying glass so the reference qualifier will be applied again when you click on the Magnifying glass.


If you don't want to use the variable of type reference, then you need to use g_for.addOption() method to add options to the Lookup Select box dynamically.


A select box will not work...I need the look of the form to have radio buttons which is what the "Lookup Multiple Choice" type provides.   I have tried to use the addOptions and removeOptions with g_form, but for some reason that doesn't work either.   Do you know if the addOptions is not supposed to work with Lookup Multiple Choice?



I also thought about some way to use a ui action to open another page for selections that can write to a temporary table that my function can query to get the values, but I don't see a way to do anything like that from the service Catalog submission form.   Any other thoughts?