Thursday, October 17, 2013

CRM 2013 FetchXML Enhancements

CRM 2011 Fetch cannot accurately express
queries of 'Left Outer Join' type. i.e. "Leads without Tasks". This limitation is mainly due to the FetchXML structure and due to its equivalent SQL query structure.

Lets see how the example 'Leads without Tasks' FetchXML gets misinterpreted in CRM 2011, and how CRM 2013 FetchXML enhancement helps to overcome it.

CRM 2011 FetchXML : 'Leads without Tasks'

Below is the fetchxml formed when to try to identify leads without tasks.

The above FetchXML gets transformed to the below SQL query. Note that the condition 'RegardingObjectID IS NULL' is appended to the 'ON Condition' yielding incorrect results.

CRM 2013 FetchXML : 'Leads without Tasks'

Below is the fetchxml formed when to try to identify leads without tasks.

The above FetchXML gets transformed to the below SQL query. Note that the condition 'RegardingObjectID IS NULL' is appended to the 'Where Condition' yielding correct results.