I am trying to create FetchXML query that will give me the Total Number of Open Leads and also the Total Number of Open Leads that do not have Open Activities against them.
I have the two queries:
Open Leads no Act:
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="true" aggregate="true" >
<entity name="lead" >
<link-entity name="task" from="regardingobjectid" to="leadid" link-type="outer" alias="task" >
<attribute name="regardingobjectid" aggregate="count" alias="TotalOpenLeadsNoActivities" />
</link-entity>
<filter type="and" >
<condition entityname="task" attribute="regardingobjectid" operator="null" />
<condition entityname="lead" attribute="statecode" operator="eq" value="0" />
</filter>
</entity>
</fetch>
AllOpenLeads:
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="true" aggregate="true" >
<entity name="lead" >
<attribute name="leadid" aggregate="count" alias="TotalOpenLeads" />
<filter type="and" >
<condition entityname="lead" attribute="statecode" operator="eq" value="0" />
</filter>
</entity>
</fetch>
Is there a way to merge them so that I simply get two "COUNT" numbers returned by one query?
Thanks.
*This post is locked for comments
Single FetchXML can't return two separate counts. Thanks.
Hi,
Using fetchxml, this wont be possible. You need to use SQL for this.
However there is a option to use Export Service and then you can make such queries.
You can read about Export Service here : msdn.microsoft.com/.../mt788315.aspx
Thanks,
PS
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,240 Super User 2024 Season 2
Martin Dráb 230,149 Most Valuable Professional
nmaenpaa 101,156