I have a DateTime item coming in from the ical binding showing me when something is going to happen from my calendar. I’m trying to take that item, subtract 2 hours from that and set that as a new dateitem’s value.
2024-06-05 18:09:39.235 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID '8507d63e20' failed: Calendar_Next_Event_Start_2Hour_Warning.postUpdate(Calendar_Next_Event_Start. ___ minusHours(2))
The method minusHours(int) is undefined for the type DateTimeItem; line 1, column 109, length 10
Any thoughts on how this can be done? I plan to use this new datetime item as a trigger on a rule.
As a followup, if I want to take my newly created 2 hour warning item and use it as a time based trigger for another rule, will this work since it is a string type item?
If it’s a String Item then no, that won’t work. But why is it a String Item? It should be a DateTime Item. The String version of the DateTime passed as an update to the Item will get parsed into a DateTime, if it’s being sent to a DateTime Item and is parsable.
the need to call toString is really just a quirk of Rules DSL and is a way to work around it’s flakey typing system. You’ll notice that the call to toString isn’t there for any of the other languages.
I think I made an error when I first created my new item and created it as a string item. I changed it to a datetime item and reran my rule and all is now set. Appreciate the explanation!