Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

283
Visualizações
How to output a JavaScript code in Zapier Code properly

I have a Zap that is triggered everytime a new Facebook LeadAd is generated. In the second step I created a JS code to match some fields of the leadad (Adset Name + Term) with a property of an object inside an array of objects with filter function.

Example:

let campaign = inputData.adset_name + inputData.term;

let logic = [
        {
            Campaign: "Adsetname+term",
            Doctors: "Name 1 - Name 2",
            ID: "xxxxxxxx - yyyyyyyy",
            Count: "2",
            Zone: "Neighborhood",
            UF: "City"
        }
//There's a lot of these objects inside the array with other data.
]

let filtro = logic.filter(x => {
    return x.Campaign === campaign;
});


output = [
  {
    ID: filtro.ID,
    UF: filtro.UF,
    Count: filtro.Count
  }
];

The main goal here is to match the incoming adset name + term with the adset name + term of a determined object inside the array, so it will return the other info linked to this specific object.

But the code isn't outputing any info into this object created. It runs with no errors, bur returns no data of the object.

Result of the step test

Do you know what I am doing wrong?

about 4 years ago · Santiago Gelvez
1 Respostas
Responde à pergunta

0

In your code, filtro is set to a filtered array of objects:

filtro = [
  {ID: 'asdf', UF: 'qwer'}
]

In your output, you're accessing filtro.ID, which is undefined. An Array doesn't have an ID property.

Instead, you probably want ID, UF and Count for each item in filtro. In that case, you can use the Array.map function:

output = filtro.map(item => {
  return {
    ID: item.ID,
    UF: item.UF,
    Count: item.Count
  }
})

This will return an array of objects. If this code is an action (instead of a trigger) subsequent zap steps will run for each item you return. See these docs for more info.

about 4 years ago · Santiago Gelvez Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda