Dynamic Reference variable
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2022 05:15 AM
Hello all,
What would be the best solution to achieve the following:
1. I have variable X on item that is a select box with values Private and Public
2. I have reference variable to Server table
3. I need reference variable to filter dynamically entries from Server table in a way that:
- if variable X is Private, then show only records from Server table with Hosting Zone= Private Cloud
- if variable X is Public, then show only records from Server table with Hosting Zone = Public Cloud
- additionally, it should filter records with Installed? = Yes
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2022 05:32 AM
Try something like below in reference qualifier of reference variable. Make sure that variable and field backend names and values are correct.
javascript: var qur = 'installed=yes';
if(current.variables.<backend_name_of_variable_x> == 'Private'){
qur += 'hosting_zone=private';
} else if(current.variables.<backend_name_of_variable_x> == 'Public'){
qur += 'hosting_zone=public';
}
qur;
In variable attribute use below statement.
ref_qual_elements=<backend_name_of_variable_x>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2022 05:35 AM
Hi Dawid,
You can create an advanced reference qualifier on the reference variable field.
Then you can do either of these:
1) Create a script include which accepts the value of variable X as argument and returns the list of Servers as per your condition.
javascript: new fetchServers(current.X); and then create the script include fetchServers to return the list.
2) Build a encoded if else query directly from the reference qualifier script condition:
Something like this:
javascript: var fetchServers; if (current.X=='Private') fetchServers= 'installed=true^hosting_zone='Private Cloud''; else fetchServers= 'installed=true^hosting_zone='Public Cloud''; fetchServers;
You can mark my answer as correct if it solves your issue or mark it as helpful if it is relevant for you!
Best Regards