The release of Microsoft Dynamics CRM 2015 Update 1 has added more granularity levels than in the past to query for date and time values like hours, days, weeks and so on using the “Older Than” clause. Previously, users could only query for dates “Older Than X Months” using FetchXML and QueryExpression. This limited the ability to query a specific set of past records. For example, if you wanted to find records older than X days, you were pretty much out of luck. With the new features in Update 1, however, you can search a multitude of different clauses, and in today’s blog, we will delve into what those clauses are!
The new granularity levels added for the “Older Than” clause in FetchXML and QueryExpression are listed below:
- Older Than X Minutes
- Older Than X Hours
- Older Than X Days
- Older Than X Weeks
- Older Than X Years
Below is an example of using FetchXML Older Than find incidents that are older than 15 minutes:
<fetch>
<entity name=”incident”>
<attribute name=”title” />
<attribute name=”ticketnumber” />
<attribute name=”createdon” />
<attribute name=”incidentid” />
<filter type=”and”>
<condition attribute=”createdon” operator=”olderthan-x-minutes” values =”15” />
</filter>
</entity>
</fetch>
Use the following syntaxes to specify various “Older Than” clauses in a FetchXML expression:
- Older Than X Minutes
<condition attribute=“<AttributeName>” operator=”olderthan-x-minutes” values=”<VALUE>” />
- Older Than X Hours
<condition attribute=“<AttributeName>” operator=”olderthan-x-hours” values=”<VALUE>” />
- Older Than X Days
<condition attribute=“<AttributeName>” operator=”olderthan-x-days” values=”<VALUE>” />
- Older Than X Weeks
<condition attribute=“<AttributeName>” operator=”olderthan-x-weeks” values=”<VALUE>” />
- Older Than X Years
<condition attribute=“<AttributeName>” operator=”olderthan-x-years” values=”<VALUE>” />
This new feature is available for CRM on-premises and online. That’s all for today, readers! If you’re interested in learning more about the new features included in CRM 2015, check out our website, and make sure you check our blog weekly for more great tips and tricks for CRM as well as news and updates weekly!
Happy CRM’ing!