HPE Morpheus Enterprise
1855738 Members
6148 Online
104103 Solutions
New Discussion

Why does this not work?

 
Not applicable

Why does this not work?

This is regular ol’ Javascript, right? Why am I gettting an error trying to filter the resultant strings that come back?

if (input.targetcloud && input.targetgroup) {
for (var x = 0; x < data.length; x++) {
if data[x].name.includes(“dhcp”)
results.push({name:data.name, value:data.id});
}
}

4 REPLIES 4
Not applicable

Re: Why does this not work?

Could you please confirm straight quotation marks (" ") around DHCP.

if (data.name.includes("dhcp")) {
Not applicable

Re: Why does this not work?

I got it working with this finally:

if (input.targetcloud && input.targetgroup) {
  for (var x = 0; x < data.length; x++) {
    name = data[x].name;
    let ans = name.includes("dhcp") 
    if (ans)
      results.push({name:data[x].name, value:data[x].id});
  }
}
Not applicable

Re: Why does this not work?

Error Executing Javascript Translation Script for OptionTypeList CAT-NETWORKLIST - SyntaxError: Unnamed:9:27 Expected an operand but found error if (data.name.includes(“dhcp”)) { ^ Unnamed:11:4 Expected eof but found } } ^

Not applicable

Re: Why does this not work?

Hi Wittling,

could you please try the below? Could you please confirm if you comment the IF condition, is that works?
if (input.targetcloud && input.targetgroup) {
for (var x = 0; x < data.length; x++) {
if (data.name.includes(“dhcp”)) {
results.push({ name: data.name, value: data.id });
}
}
}

Thanks
Velan