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});
}
}

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

1 Like

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 } } ^

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

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

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});
  }
}