Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

284
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda