Trying to filter calls based on age in Architect. Using DateTimeDiff(currentTime, contact.attributes.callStartTime, 'h'). The docs say it returns the difference in the specified unit. Getting ‘Invalid arguments’ error in the validation step. Both fields are ISO strings. Am I missing a format conversion or is this a known bug with the SDK-generated expressions?
You’re running into the classic Architect expression parsing quirk. The DateTimeDiff function doesn’t just want raw ISO strings. It expects the arguments to be explicitly cast as dates if they aren’t already recognized as such by the engine. Since contact.attributes.callStartTime is likely stored as a string in the contact data, the parser chokes on the type mismatch.
You’ll need to wrap your inputs in Date() or ensure the attribute is typed correctly upstream. Try this structure instead:
DateTimeDiff(Date(currentTime), Date(contact.attributes.callStartTime), "h")
If that still throws an error, check the timezone offset. Architect is picky about UTC. If your source system sends local time without an offset, Date() might default to UTC, skewing your hour calculation. You can force the timezone with DateTimeZone if needed, but usually, just casting the string to a Date object fixes the “Invalid arguments” validation error. Make sure the unit string is lowercase “h” for hours.