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

134
Vistas
Register Javascript reply from JXA

Back again with a JavaScipt / JXA question. I'm trying to register a response from a application that I'm calling with JXA. I am trying to register the value app.toDos.byId("HQebK1em72yZqc3WqTmyzx"). When I kick of the following script:

var TaskApp = Application('Things3')

var toDo = TaskApp.ToDo({
  name: "A new task",
  notes: "notes"
})

var newTask = TaskApp.toDos.push(toDo)

console.log("Task " + newTask)

I get the following output in the Replies field:

app = Application("Things")
    Application("Things").toDos.push(app.ToDo({"name":"A new task", "notes":"notes"}))
        --> app.toDos.byId("HQebK1em72yZqc3WqTmyzx")
    Application("Things").toDos.length
        --> 3502

/* Task 3502 */
Result:
undefined

This looks like this in the editor: enter image description here

The value newTask seems to be overwritten by the .push method which returns the array length. Can I somehow register or return the new task ID that is returned by the application?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

That is expected: push is a JavaScript standard library method that always returns the array length. Just do this instead:

var TaskApp = Application('Things3')

var toDo = TaskApp.ToDo({
  name: "A new task",
  notes: "notes"
})

TaskApp.toDos.push(toDo)

console.log("Task " + toDo.id())
about 4 years ago · Juan Pablo Isaza 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