Multi Row Variable Set Reference variables

SaiBhargav1
Kilo Contributor

Hi all,

I have requirement on service catalogs , i used multirow variable set . Requirement

as part of my requirement i have created two Multi row variable sets 

1st variable set variable are Asset id (reference asset table) , SAP number

2nd variable set variables are Asset id(reference asset table) , asset found

 

1st variable set is for end user 2nd is for task person.

 

in the 1st variable set user selected the two items and submitted the request , then task person in the 2nd variable set once click the asset id in that it should display what are the assets were selected by end user.  how to restrict that if any one knows let me know.

1st variable set here 2 assets selected

find_real_file.png

2n variable set once click on asset id it should show only those 2 assets but it's showing all the assets. how to restrict that let me know.

find_real_file.png

find_real_file.pngthanks in advance.

12 REPLIES 12

quick question here, 

are you restricting the reference field value based on other field ? if yes then in that case reference qualifier will not get invoked here, did you try to add a log in your script include to validate if your script include is getting invoked or not. 

 

Remember : 

  • Variables that are not included in a multi-row variable set cannot be used in dependent reference qualifiers for variables in the multi-row variable set. Similarly, the variables included in the multi-row variable set cannot be used in dependent reference qualifiers for variables that are not in the multi-row variable set. For a reference qualifier, the current row is the one that is being edited.

Shamma Negi
Kilo Sage
Kilo Sage

Hi Sai,

 

I tried the same it is not allowing to set the advance reference qualifier.

However , I tried it by using the onChange Client Script, that works on multi row variable set. but in that we have ti do in single multirow variable set

Please try if you can use something like in the same multirow variable set and then autopopulate other values based on asset ID selection.

If you need I can share the scrip also.

 

Regards,

Shamma

Regards,Shamma Negi

Yeah Thanks for your response. i knew it how to populate other fields based on Asset ID

And as you said i also written some client scripts and reference qualifier but not working.

Hi Sai,

 

Please go through from the below URL.

https://docs.servicenow.com/bundle/london-it-service-management/page/product/service-catalog-managem...

 

  • Variables that are not included in a multi-row variable set cannot be used in dependent reference qualifiers for variables in the multi-row variable set. Similarly, the variables included in the multi-row variable set cannot be used in dependent reference qualifiers for variables that are not in the multi-row variable set. For a reference qualifier, the current row is the one that is being edited.

IT only works on the current row.

Regards,

Shamma

Regards,Shamma Negi

Inactive_Us2019
Giga Expert

Hi sai,

I am not sure about onchange client script on multirow variable set. I tried to implement one solution that you can use in the below scenario .

You can use the below script when you have any other normal variable along with the two  multirow variable sets that you mentioned.

 

Client script:(on change of normal variable present in the form)

function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}

//Type appropriate comment here, and begin script below
var mvrs=[];
mvrs= g_form.getValue('multirow_variableset');   //The name is the internal name of multirow variable set for user

var ajax = new GlideAjax('mrvsscript');
ajax.addParam('sysparm_name','addref');
ajax.addParam('sysparm_team',mvrs);
ajax.getXML(createout);

function createout(response){
var answer = response.responseXML.documentElement.getAttribute("answer");
g_form.addInfoMessage(answer);
}
}

--------------------------------------------------------------------------------------------------------------

Script include:

var mrvsscript = Class.create();
mrvsscript.prototype = Object.extendsObject(AbstractAjaxProcessor, {

addref:function(){
var add=this.getParameter('sysparm_team');
var json = JSON.parse(add);
var obj=[];
for(var i=0;i<json.length;i++)
{
obj.push(json[i].asset_id);
}
var p='';
for(var j=0;j<json.length;j++)
{
p=p+'sys_id='+obj[j].toString()+'^OR';
}
var gr = new GlideRecord('item_option_new');
gr.addQuery('sys_id','0da567383712330011eeea4873990efc'); // sys_id of asset id variable in second multirow variable set
gr.query();
gr.next();
gr.setValue('use_reference_qualifier','advanced');
gr.setValue('reference_qual',p);
gr.update();

return obj;
},

type: 'mrvsscript'
});

 

This works perfectly fine when you have one more variable which you can fill after filling the multirow variable set for user. For better understanding please see the attachment.

 

 

Please mark correct if this is helpful!!