Hi all, new to AppleScript so I figured I’d have more luck with JXA, but it seems even more inscrutible.
I’m trying to use the REPL to suss out the methods and structure, but I can’t use the normal JavaScript approaches as I don’t get a human-readable representation, just a lot of “can’t convert types” errors. Is there an approach to suss out the methods and attributes of an object in JXA?

Ultimately, I’m trying to make a script that dumps a list of flattened tasks from a perspective in a structured data format (prefereably JSON). I plan to feed this to Alexa so I can have my daily tasks as part of my “flash briefing”.

I am getting stuck on how to flatten and iterate through the contentTree to pull out the individual tasks.

I tried the approach @unlocked2412 suggested in another thread for pulling all the tasks in the database, but it seemed a bit slow and I would rather not duplicate the perspective filters.

Perhaps that is a better approach, since this way changes the perspective in the current window which will be a problem when I’m trying to work and this script runs in the background.

Happy to help! In the Utilities folder on your Mac, you’ll find one named Script Editor; go ahead and drop OmniFocus’ app icon onto Script Editor. This will open up a window which shows the AppleScript commands which are available. (You can do this with any app that offers an AppleScript interface; it’s not OmniFocus-specific.)

The browser defaults to AppleScript, but there should be a “Language” item in the toolbar which will let you switch between AS, JavaScript, and Objective-C formatting.

By what’s in the AppleScript dictionary they don’t seem to, but they functionally do on the watch. My watch face is configured to show me the first task in one of my perspectives (which I have configured to be the task I should probably be working on right now). I’d like to get show that task on my menu bar on my Mac too.

Since the perspective rules aren’t exposed via scripting either, I don’t think there’s a way to do that without completely reimplementing the perspective in Apple/JavaScript, and then keeping it up to date if I ever change the perspective, which sounds pretty terrible.