Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Filter data in CRM Chart XML

Posted on by Microsoft Employee

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

  • Suggested answer
    a33ik Profile Picture
    a33ik 84,323 Most Valuable Professional on at
    RE: Filter data in CRM Chart XML

    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>

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Filter data in CRM Chart XML

    Thanks much. This works.

    How about filtering data for last 5 weeks?

  • Suggested answer
    a33ik Profile Picture
    a33ik 84,323 Most Valuable Professional on at
    RE: Filter data in CRM Chart XML

    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
    Community Member Microsoft Employee on at
    RE: Filter data in CRM Chart XML

    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
    Community Member Microsoft Employee on at
    RE: Filter data in CRM Chart XML

    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
    a33ik 84,323 Most Valuable Professional on at
    RE: Filter data in CRM Chart XML

    I just used Advanced Find for this purpose:

    6036.AF.png

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Filter data in CRM Chart XML

    How did you get 4202 and 4210?

  • Verified answer
    a33ik Profile Picture
    a33ik 84,323 Most Valuable Professional on at
    RE: Filter data in CRM Chart XML

    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>


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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans