I am encountering a confusing issue while working with KBM. I have a single macro with two separate actions: Action 1 & Action 2. Each action is executing the same JavaScript file for Automation (JXA). The script simply logs "hello" to the OmniFocus console. However, one action works as expected, while the other generates a TypeError.
Any help in understanding what the heck is going on would be greatly appreciated!
Here are the details:
SETUP
Action 1:
- This action was copied from another macro and works without issues.
- It successfully logs "hello" in the OmniFocus console.
Action 2:
- This action was created fresh within the current macro and points to the exact same script file.
- This action fails with the following error (details below).
SCRIPT USED BY BOTH ACTIONS
(() => {
"use strict";
// ------------------- OMNIJS CODE -------------------
const OmniJS = () => {
console.log("hello");
};
// -------------------- JXA CODE ---------------------
const main = () => {
return evalOmniJSWithArgs(
"OmniFocus",
OmniJS,
""
);
};
// --------------------- GENERIC ---------------------
// evalOmniJSWithArgs :: Function ->
// [...OptionalArgs] -> a
const evalOmniJSWithArgs = (appName, f, ...args) => {
return Application(appName).evaluateJavascript(
`(${f})(${args.map(JSON.stringify)})`
);
};
return main();
})();
ERROR LOG GENERATED BY ACTION 2
2025-01-22 15:32:09 Execute a JavaScript For Automation failed with script error:
Error: TypeError: {
}
is not a function. (In '{
}
(() => {
"use strict";
// ------------------- OMNIJS CODE -------------------
const OmniJS = () => {
console.log("hello");
};
// -------------------- JXA CODE ---------------------
const main = () => {
return evalOmniJSWithArgs(
"OmniFocus",
OmniJS,
""
);
};
// --------------------- GENERIC ---------------------
// evalOmniJSWithArgs :: Function ->
// [...OptionalArgs] -> a
const evalOmniJSWithArgs = (appName, f, ...args) => {
return Application(appName).evaluateJavascript(
`(${f})(${args.map(JSON.stringify)})`
);
};
return main();
})', '{
}
' is an instance of Object) (-2700)