Saturday, 16 April 2016

Filter Records Based On Related Entity - FetchXML Query

In the following example, the FetchXML statement retrieves all accounts where the last name of the owning user is not equal to Cannon:
  1. <fetch mapping='logical'>
  2. <entity name='account'>
  3. <attribute name='accountid'/>
  4. <attribute name='name'/>
  5. <link-entity name='systemuser' to='owninguser'>
  6. <filter type='and'>
  7. <condition attribute='lastname' operator='ne' value='Cannon' />
  8. </filter>
  9. </link-entity>
  10. </entity>
  11. </fetch>
Explanation
  • To filter entity records add <link-entity> clause, ex <link-entity name='systemuser' to='owninguser'> . Where name attributes contains linked entity logical name and to attribute contains logical name of attribute in main entity which is linked to related entity
  • Specify filter clause within link-entity.
  • Within filter specify the filter criteria using <condition attribute='lastname' operator='ne' value='Cannon' /> . Where attribute contains logical name of attribute in related entity, operator defines the comparison type here ne means not-equal and value defines the value to compare.
- See more at: http://msxrmtools.com/fetchxml/reference

No comments:

Post a Comment