web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Filter data in CRM Chart XML

(0) ShareShare
ReportReport
Posted on by

I am trying to filter Activities data based on "activity type" i.e  Filter all records for a chart that has values "Email" and "Phone call".  Here is the code I am trying to use which is not working. 

<entity name="activitypointer">
<attribute name="createdon" groupby="true" alias="_CRMAutoGen_groupby_column_Num_0" dategrouping="day" />
<attribute name="subject" aggregate="count" alias="_CRMAutoGen_aggregate_column_Num_0" />


<link-entity name="Activities" from="activitytypecode" to="activitytypecode" link-type="outer">
<attribute name="activitytypecode" groupby="true" alias="_CRMAutoGen_groupby_column_Num_13" />
<filter>
<condition attribute="activitytypecode" operator="or" >

<value>"Email"<value/>

<value>"Phone call"<value/>

</condition>
</filter>
</link-entity>


</entity>

Any suggestions? 

*This post is locked for comments

I have the same question (0)
  • Verified answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at

    Hello,

    You don't need to make any joins to organize filtering. Check following FetchXml:

    <fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
      <entity name="activitypointer">
        <attribute name="activityid" />
        <attribute name="subject" />
        <filter type="and">
          <condition attribute="activitytypecode" operator="in">
            <value>4202</value>
            <value>4210</value>
          </condition>
        </filter>
      </entity>
    </fetch>


  • Community Member Profile Picture
    on at

    How did you get 4202 and 4210?

  • Suggested answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at

    I just used Advanced Find for this purpose:

    6036.AF.png

  • Community Member Profile Picture
    on at

    Oh wow! that's a smart way.

    Another issue is. I have another CRM chart in which I am using some different attributes from activity but still I want to filter data based on Activity type . Here is the code:

    <fetch mapping="logical" aggregate="true">

             <entity name="activitypointer">

               <attribute name="subject" aggregate="count" alias="_CRMAutoGen_aggregate_column_Num_0" />

               <attribute name="createdby" groupby="true" alias="_CRMAutoGen_groupby_column_Num_13" />

               <attribute name="createdon" groupby="true" alias="_CRMAutoGen_groupby_column_Num_14" dategrouping="day" />

             </entity>

           </fetch>

  • Community Member Profile Picture
    on at

    Oh wow! that's a smart way.

    Another issue is. I have another CRM chart in which I am using some different attributes from activity but still I want to filter data based on Activity type . Here is the code:

    <fetch mapping="logical" aggregate="true">

             <entity name="activitypointer">

               <attribute name="subject" aggregate="count" alias="_CRMAutoGen_aggregate_column_Num_0" />

               <attribute name="createdby" groupby="true" alias="_CRMAutoGen_groupby_column_Num_13" />

               <attribute name="createdon" groupby="true" alias="_CRMAutoGen_groupby_column_Num_14" dategrouping="day" />

             </entity>

           </fetch>

  • Suggested answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at

    Try to use following FetchXml query:

    <fetch mapping="logical" aggregate="true">
    	<entity name="activitypointer">
    		<attribute name="subject" aggregate="count" alias="_CRMAutoGen_aggregate_column_Num_0" />
    		<attribute name="createdby" groupby="true" alias="_CRMAutoGen_groupby_column_Num_13" />
    		<attribute name="createdon" groupby="true" alias="_CRMAutoGen_groupby_column_Num_14" dategrouping="day" />
    		<filter type="and">
    			<condition attribute="activitytypecode" operator="in">
    				<value>4202</value>
    				<value>4210</value>
    			</condition>
    		</filter>
    	</entity>
    </fetch>


  • Community Member Profile Picture
    on at

    Thanks much. This works.

    How about filtering data for last 5 weeks?

  • Suggested answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at

    Hello,

    Have you tried to do anything before asking here? Advanced find can give you result. Here is what I got:

    <fetch mapping="logical" aggregate="true" >

     <entity name="activitypointer" >

       <attribute name="subject" aggregate="count" alias="_CRMAutoGen_aggregate_column_Num_0" />

       <attribute name="createdby" groupby="true" alias="_CRMAutoGen_groupby_column_Num_13" />

       <attribute name="createdon" groupby="true" alias="_CRMAutoGen_groupby_column_Num_14" dategrouping="day" />

       <filter type="and" >

         <condition attribute="activitytypecode" operator="in" >

           <value>4202</value>

           <value>4210</value>

         </condition>

         <condition attribute="createdon" operator="last-x-weeks" value="5" />

       </filter>

     </entity>

    </fetch>

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans