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

204
Vistas
The variable is not defined, but it is

I have declared global variables at the top of the script, and I have initialised them.

I can set the "do JavaScript" to the variable "emptyDue" fine. But then as soon as I try to compare the result of the JavaScript to the serviceDate variable, I get: "error "The variable emptyDue is not defined." number -2753 from "emptyDue"".

Why can I assign emptyDue on one line, and then on the very next line, it suddenly forgets that it should exist?

global emptyDue, serviceDate
set emptyDue to ""
set serviceDate to "2021-11-30"

on isEmptyDue()
    
    tell application "Safari" to tell document 1
        
        set emptyDue to do JavaScript "document.getElementById('trgUseNext').click();
 document.getElementById('trgUseNext').value; --gets the date value from a webpage."
        
        if emptyDue < serviceDate then
            display dialog "TRUE"
        else
            display dialog "FALSE"
        end if
        
    end tell
    
end isEmptyDue

isEmptyDue()
log emptyDue
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

There is a known flaw in AppleScript’s design: it is possible for a command to return no value. If you then bind the result of that command to a variable, it effectively makes that variable undefined.

You can avoid that -2753 error by making sure your command always returns a value, even if that value is just an empty string.

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