- Community Home
- >
- Software
- >
- HPE Morpheus Software
- >
- HPE Morpheus Enterprise Software
- >
- Query array in optionlist logic for networks
Categories
Company
Local Language
Forums
Discussions
- Integrity Servers
- Server Clustering
- HPE NonStop Compute
- HPE Apollo Systems
- High Performance Computing
Knowledge Base
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Knowledge Base
Forums
Discussions
- Cloud Mentoring and Education
- Software - General
- HPE OneView
- HPE Ezmeral Software platform
- HPE OpsRamp Software
Knowledge Base
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2024 06:47 AM
03-26-2024 06:47 AM
Hi,
I’m trying to refine our optionlist logic for selecting networks:
Currently I have:
for(var x=0;x < data.networks.length; x++) {
if (data.networks.dhcpServer == true && data.networks.visibility == “public” && data.networks.labels.length > 0) {
results.push({name: data.networks.name, value: data.networks.id});
}
}
Which works, however I would like to refine.
Basically I want to match the contents of data.networks.labels so if a label is set as “provisioning” it’s selected.
I have tried data.networks.labels == “provisioning” but it does not pick up. I have tried data.networks.labels.includes (‘provisioning’) but the query errors as it does not like includes,
When I query the API, I say it’s: -provisioning.
Any ideas on the correct syntax to use?
Solved! Go to Solution.
- Tags:
- option-lists
- Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2024 08:49 AM
03-26-2024 08:49 AM
Re: Query array in optionlist logic for networks
Thanks that is now working.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2024 05:17 AM
04-26-2024 05:17 AM
Re: Query array in optionlist logic for networks
I’m trying to refine the logic so if it finds “provisioning” in first or second element of the array. But cannot get the logic to work.
for(var x=0;x < data.networks.length; x++) {
if (data.networks.dhcpServer == false && data.networks.visibility == “public” && data.networks.labels.length > 0) {
if (data.networks.labels[0].includes(‘provisioning’) || data.networks.labels[1].includes(‘provisioning’)) {
results.push({name: data.networks.name, value: data.networks.id});
}
}}
What am I missing?
Cheers
Jon
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2024 06:09 AM
04-26-2024 06:09 AM
Re: Query array in optionlist logic for networks
Found the fix:
for(var x=0;x < data.networks.length; x++) {
if (data.networks.dhcpServer == false && data.networks.visibility == “public” && data.networks.labels.length > 0) {
if (data.networks.labels[0].includes(‘provisioning’)){
results.push({name: data.networks.name, value: data.networks.id});
}
}
if (data.networks.dhcpServer == false && data.networks.visibility == “public” && data.networks.labels.length > 1) {
if (data.networks.labels[1].includes(‘provisioning’)){
results.push({name: data.networks.name, value: data.networks.id});
}
}}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2024 07:10 AM