Passing variable value to script includes in a reference qualifier
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-03-2019 07:21 PM
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.
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-03-2019 07:42 PM
Hi Evan -
Is this within the Catalog Item as the user fills out the form prior to submission?
- if yes, the value of the variable has to be caught using the client methods e.g. g_form.getValue('variable_name');
Or is this post-submission and you're on the created record?
- if yes, and this is in a business rule, the value has to be accessed via server methods through the variables on the 'current' record e.g. current.variables.variable_name;
- if yes, and this is in a client script or UI policy, you'll need to go back to the client methods of g_form.getValue('variables.variable_name');
Let me know if this was helpful or not. If I'm totally off base on where you're trying to apply this, please set me straight.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-03-2019 07:53 PM
I just re-read your post and realized I missed the point that this is for a Ref Qualifier on a reference variable. You'll have to use javascript: new SSLCertUtils().filterNodesOnPlatform(current.variables.platform);
Let me know if that works or not.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-03-2019 09:11 PM
Thanks for responding.
Unfortunately that didn't work, when i output the value out what was passed to the function it comes out as undefined.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2019 05:46 AM
OK, let's try this: don't pass a parameter with your ref qual. Just use:
new SSLCertUtils().filterNodesOnPlatform();
Then, in your script include change it up a bit like this:
filterNodesOnPlatform: function (){
var query;
var platform = current.variables.platform;
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;
},