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

133
Visualizações
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 Respostas
Responde à pergunta

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