The following makes the automation console spit an error at >>: Property Task.deferDate requires a Date, but was passed value of type Number - and for the life of me I can’t figure out why if I am passing a Date.
I am trying to defer an item by 7 days.
[…]
var d = new Date()
var defer = d.setDate(d.getDate() + 7)
[…]
const defer = new Date ( d.setDate(d.getDate() + 7) )
And, incidentally, we get more helpful messages back from the JavaScript interpreter if we use const by default and let for the rarer occasions when we really want and need to reassign a name to a different value.
var has tricky behaviour that can trip us up, is no longer needed, and is now generally deprecated. See, for example:
The author of omni-automation.com seems to have a dirty habit of polluting the global name space by assigning names in it, and uses var to suppress the helpful error messages from JavaScript which this leads to :-)