Hi,
I’m currently testing deploying to two VMware clouds.
I’m using the networks REST option list do pull down the available networks using this translation script:
if (input.selectedCloud && input.selectedGroup) {
for(x in data.networks){
if (data.networks.dhcpServer == (true))
{
results.push({name:data.networks.name, value:data.networks.id});
}}}
Which works for displaying dhcp subnets, however it’s showing all entries. Rather only showing entries for the selected cloud.
For the input to this network optionlist I have added the dependant field as selectedCloud which is the fieldname for the cloud, but has not helped.
Any ideas what I need to tweak to only pull down the the networks for the cloud selected?
Cheers
Jon
I think you need an additional conditional test. In the for loop you don’t check that input.selectedCloud
(id) equals the networks cloud id before pushing to the results, which is why you’re getting everything. If you apply that test, it will provide the filtering
Hopefully I understand you, I have changed to:
for(x in data.networks){
if (data.networks.dhcpServer == (true))
{
results.push({name:data.networks.name, value:data.networks.id});
}}
But it still lists everything
Try this, I’ve mocked it up based on the apidocs network response:
Edit: I note, there’s only 1 network in the data set but you can change input.selectedCloud on line 102 to validate that it is picked up only if there is a id match.
Adding the code from that demo here too. Just in case of links policies
let results = [];
for (let x=0; x< data.networks.length; x++){
if (data.networks[x].zone.id == input.selectedCloud){
results.push({name: data.networks[x].name, value:data.networks[x].id})
}
}
Thanks Ollie,
I had to get rid of
let results = ;
As it complains there were too many results, but this works and the networks are filtered
Yes, that was an artifact of the test code. Glad you are sorted