Forum Discussion
Hello,
I don't see anything in particular that would cause the date in that AML to be recognized as invalid. The system does check for a particular format which you can generate from a .NET DateTime object by using DateTime.ToString("yyyy-MM-ddTHH:mm:ss"); .
Would you be able to share your method code for this onBeforeGet event? I think the issue may be coming from the structure of that method itself. Typically an onBeforeGet is done for validation and query modification purposes. The this object passed into this event is an Item that represents the query about to be performed. To modify this query, you can simply update and return the this object without applying it. You can see an example of how to replace the string "yesterday" with a query to search on yesterday's date in the Gist below.
https://gist.github.com/cgillis-aras/a925e60fcf77d9b0a582ea703f1eab8f
In this Gist, I've also modified the AML you provided slightly to use the between condition rather than using a gt and a lt on two different properties.
To answer your second question about reusability, it would be possible to create a custom search mode that allowed strings like "yesterday" or "tomorrow" to be passed in to date properties. You can also look at the sample code in this forum post to see how another user implemented relative date searches. Note that the user in that post modified a core file in the codetree which we do not recommend doing. However, you could use the code provided there in a custom search mode to achieve a similar result.
I hope the sample code and information helps! Let me know if you have any follow up questions.
Chris
Christopher Gillis
Aras Labs Software Engineer