Goal: Make a view that can show all Contacts owned by the current user, and any Contacts with an associated opportunity owned by the current user.
Problem: I don't have a great command of fetchxml or linkentities even after reviewing what I can Google about them. When I try to build the view using my fetch statement it's not bringing back anything so I assume I've constructed it incorrectly.
Here is the statement I've made so far:
<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='true'>
<entity name='contact'>
//big list of attributes
<order attribute='fullname' descending='false' />
<link-entity name='opportunity' from='customerid' to='contactid' alias='aa'>
<filter type='and'>
<condition attribute='ownerid' operator='eq-userid' />
</filter>
</link-entity>
<filter type='or'>
<condition attribute='ownerid' operator='eq-userid' />
</filter>
</entity>
</fetch>
Any tips would appreciated, thanks!
You've checked CRM 2011 and CRM 2013. With CRM 2011, this is not possible. With CRM 2013, you can do this!
<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='true'>
<entity name='contact'>
<attribute name='fullname' />
<order attribute='fullname' descending='false' />
<link-entity name='opportunity' from='customerid' to='contactid' alias='aa' link-type='outer'>
<attribute name='name' />
</link-entity>
<filter type='or'>
<condition attribute='ownerid' operator='eq-userid' />
<condition entityname='aa' attribute='ownerid' operator='eq-userid' />
</filter>
</entity>
</fetch>
You'll note, the alias referenced in the filter and you have to use an outer join.
I've added a blog post to provide a little bit of a walk through for anyone who is interested: http://paul-way.com/crm-2013-fetchxml-improvements/