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
document.getElementById('trgUseNext')you are trying to use.