I agree. I tried it again, and the whole thing smells extremely fishy. I manage to get a meaningful
app.logMessage(records.length.toString())
so the JS function does get an object that has a length
property. But apart from that, no luck: iterating over the records just does nothing, it seems (tried for i = 0...
, for (r in records)
and records.forEach()
so far).
In my opinion, DT’s inner workings leave something to be desired here. Given that JavaScript code outside of a smart rule works ok generally, I suppose that these problems result from the implementation of the interface to the scripting language in smart rules. Seeing that Hazel has no problems in doing exactly the same thing here, it seems to be possible to support both languages for external scripts.
Given that JS is wastly more popular then AppleScript nowadays and it is the only way to have automation on i*OS, I hope that this will be fixed.