Filter or Add/Remove choices in a variable in multi-row variable set

Meghana Jannava
Tera Contributor

Hello Team,

I have three variables of type reference, lookup select box and select box in a mulit-row variable set.

Is it possible to filter out the choices in drop-down (for reference or lookup select box) or add/remove choices (select box) in the mrvs based on the value of a select box present in the catalog item?

 

Thanks,

Meghana.

1 ACCEPTED SOLUTION

You can't set the choices of a MRVS select box from the catalog item, but since you are using Service Portal, if you add this onLoad script to the catalog item

function onLoad() {
	if (this) {//we only need to do this for Service Portal
		//We need to make the g_form object for the parent item available from the MRVS window
		this.cat_g_form = g_form;
	}
}

you can access catalog item variables from a script within the MRVS like this

if(this){ //Service Portal method
  if(this.cat_g_form.getValue('variable_name') == 'Choice1'){
    g_form.addOption('var_name', 'label', 'value');
    g_form.removeOption('var_name', 'value');
  }
}
else{ //native UI method
  if(parent.g_form.getValue('variable_name') == 'Choice1'){
    g_form.addOption('var_name', 'label', 'value');
    g_form.removeOption('var_name', 'value');
  }
}

View solution in original post

6 REPLIES 6

Brad Bowman
Kilo Patron
Kilo Patron

This may be possible in reference qualifiers with the changes coming in the Quebec release.  The workaround for Paris and earlier is to add a variable to the MRVS that is populated with the value of the select box from the catalog item.  You can't hide this variable (until Quebec) but you can make it read-only.  For the MRVS select box, you can add/remove options with an onLoad Catalog Client Script within the MRVS.  The syntax for this if you are only using the native UI is

if(parent.g_form.getValue('variable_name') == 'Choice1'){
  g_form.addOption('var_name', 'label', 'value');
  g_form.removeOption('var_name', 'value');
}

Let me know if you are using the Service Portal as there is a hope to jump through before being able to access a variable in the Catalog Item from the MRVS.

Yes, filtering this way is certainly possible. I have already tried reference qualifier for lookup select box and it works if I have the both the variables in either variable set or directly on the catalog item in portal.

Unfortunately I need to hide the variable on the form which we are unable to as you have also mentioned.

 

Quick question : Do you know if it's possible for us to set the choices of a select box in MRVS directly from a client script in the catalog item ?


and I mentioned client script in the catalog item because I'm unable to fetch the value of the (dependent) variable present in catalog item in a client script of a variable set.

I am trying to achieve the requirement this way also if it's possible.

You can't set the choices of a MRVS select box from the catalog item, but since you are using Service Portal, if you add this onLoad script to the catalog item

function onLoad() {
	if (this) {//we only need to do this for Service Portal
		//We need to make the g_form object for the parent item available from the MRVS window
		this.cat_g_form = g_form;
	}
}

you can access catalog item variables from a script within the MRVS like this

if(this){ //Service Portal method
  if(this.cat_g_form.getValue('variable_name') == 'Choice1'){
    g_form.addOption('var_name', 'label', 'value');
    g_form.removeOption('var_name', 'value');
  }
}
else{ //native UI method
  if(parent.g_form.getValue('variable_name') == 'Choice1'){
    g_form.addOption('var_name', 'label', 'value');
    g_form.removeOption('var_name', 'value');
  }
}

Thank you Brad, the code in your previous post was really helpful. I was able to filter the choices in MRVS.