Passing variable value to script includes in a reference qualifier

Evan7
Tera Contributor

Hi All, 

I have a rather complex form that uses a couple of variable sets as well on form variables. What I'm trying to do is pass the value from a variable in variable to the reference qualifier of the second variable set.

To put it in context I'm trying to pass the value of a "platform" e.g. IIS, I H S, Oracle etc.... through to a Multi Row Variable Set that references the CMDB and filters it accordingly so for IIS will only show windows servers.

So in the advanced reference qualifier of the MRVS I have:

javascript: new SSLCertUtils().filterNodesOnPlatform(current.platform);

The script includes looks like:

filterNodesOnPlatform: function (platform){
var query;

switch (platform){
case "web_iis":
query = 'operational_status=1^sys_class_name=cmdb_ci_win_server^EQ';
break;
case "web_ihs":
query = 'operational_status=1^sys_class_name=cmdb_ci_unix_server^EQ';
break;
default:
query = 'operational_status=1;
}
return query;
},

When I output the value of 'platform' in the script above i get 'undefined'. I have tried all sorts of combinations and nothing seems to work.

When i just pass current and output it i get [object GlideRecord] but i can't find anyway to use this to look up the variable value.

Can someone help me out here.

12 REPLIES 12

Evan7
Tera Contributor

Just to provide an update on this. After some digging a colleague found this on the ServiceNow Docs site.

NOTE:

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.

 

So basically what i'm trying to do wont work and will either need to redesign the form to include the platform in the MRVS or come up with some other workaround for it. 

 

hello I have a similar requirement did you get to something with this ?

Yogev A_
Giga Contributor

Hi Evan,

I saw a workaround of what you're looking for.

https://jace.pro/post/2019-11-19-setting-vars-in-a-mrvs-from-outside/

Hope it helps