Using Advanced Find, I can search for Opportunities where the Opportunity Type is a particular value and an Opportunity Product in the Opportunity is a particular Opportunity Product.
<entity name="opportunity" >
<attribute name="name" />
<order attribute="name" descending="false" />
<filter type="and" >
<condition attribute=" opportunitytype" operator="eq" value="100000018" />
</filter>
<link-entity name="opportunityproduct" from="opportunityid" to="opportunityid" alias="af" >
<filter type="and" >
<condition attribute="productid" operator="in" >
<value uiname="some product name here" uitype="product" >{some product ID here}</value>
</condition>
</filter>
</link-entity>
</entity>
Great. But is there any way I can search for Opportunities where the Opportunity Type is a particular value OR an Opportunity Product in the Opportunity is a particular Opportunity Product?
I know you can't do it in Advanced Find, but I'm hoping you can with FetchXML.
I'm thinking of being able to specify the link-entity outside the filter block, and then later reference the link-entity by its alias, something like this (major changes in red):
<entity name="opportunity" >
<attribute name="name" />
<order attribute="name" descending="false" />
<link-entity name="opportunityproduct" from="opportunityid" to="opportunityid" alias="af" />
<filter type="or" >
<condition attribute=" opportunitytype" operator="eq" value="100000018" />
<condition attribute="af.productid" operator="in" >
<value uiname="some product name here" uitype="product" >{some product ID here}</value>
</condition>
</filter>
</entity>