[JS] What does theFile actually return?

Hi,
since Hazel has no script debugging capabilities, I am asking myself what does the 'theFile' variable actually return? In my case I am trying to match a folder name, which is part of the name of a project in OmniFocus. In case there is no project with such a name or it is already completed the script should return 'true'.
It matches the project perfectly if I run it the separate script editor and returns the right value, but refuses to run in hazel. Here is the script:
I've tried to simplify the functions and check for variables being a string, but it matches nothing. I suspect that 'theFile' variable probably returns a full path but I don't see a way to check it in Hazel. So, does anyone has some experience?
since Hazel has no script debugging capabilities, I am asking myself what does the 'theFile' variable actually return? In my case I am trying to match a folder name, which is part of the name of a project in OmniFocus. In case there is no project with such a name or it is already completed the script should return 'true'.
It matches the project perfectly if I run it the separate script editor and returns the right value, but refuses to run in hazel. Here is the script:
- Code: Select all
var qr = theFile
var qr = String(qr) // convert to string
var of = Application('OmniFocus');
var doc = of.defaultDocument;
function searchTasks(_query) {
return doc.flattenedTasks.whose({_and: [
{ name: { _contains: _query } },
{ completed: false }
]})();
};
var pathToTask = searchTasks(qr) // returns path to project in OF, if a match, empty if not.
var pathToTask = String(pathToTask) // convert to string
function returnStatus() {
if (pathToTask) {
return false // if not empty, return false and do nothing
} else {
return true // if empty, return true and perform actions on a folder
}
return obj
}
returnStatus()
I've tried to simplify the functions and check for variables being a string, but it matches nothing. I suspect that 'theFile' variable probably returns a full path but I don't see a way to check it in Hazel. So, does anyone has some experience?