I have this SQL
query where I am trying to fetch the opportunityId
from opportunity entity for whom approvaldocument
has not been created (approval document is the name of the other entity) .I dont think fetchxml supports such kind of query. I am new to crm and my project is in crm 4.0
version.
here's the sql query:
Select OpportunityId from opportunity AS c left JOIN (select a.opportunitynameid from opportunity o
JOIN ApprovalDocument a ON
a.opportunitynameid=o.OpportunityId) AS b ON c.OpportunityId=b.opportunitynameid
Where b.opportunitynameid IS NULL and statecode=0
I converted this into a fetchxml
, but that didn't give the correct result.
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="true">
<entity name="opportunity"> <attribute name="opportunityid" />
<link-entity name="approvaldocument" from="opportunitynameid" to="opportunityid" alias="a" link-type="outer"> <attribute name="opportunitynameid" />
</link-entity>
<filter type="and">
<condition entityname="a" attribute="opportunitynameid" operator="null" />
</filter>
</entity>
<fetch/>