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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Answered

Fetchxml query

(1) ShareShare
ReportReport
Posted on by 4
I have a requirement which says we need to get all the people involved with a contact from our organization and I need write a query to get that (from activities of all kind) from which tables i have to get these
Categories:
I have the same question (0)
  • rajeshjamrodh Profile Picture
    35 on at
    Hi ,
     
    As per the CRM application all the user action we are saving on activity table.
    you need to query the Activity tables and the ActivityParty table. The ActivityParty table is the key because it stores the participants (From, To, CC, Organizer, Required Attendee, etc.) for activity records.
     
    below all the table comes under activity tables.
    email

    phonecall

    appointment

    task

    letter

    fax

    campaignresponse

    serviceappointment and custom activity entities
  • CU21070523-0 Profile Picture
    4 on at
    From contact table how do u connect to this through which lookup?
  • Verified answer
    awad Profile Picture
    on at
     
     
    FetchXML: Contacts Involved in Activities
     
    Try using this fetch xml query using the XRM Tool box first and then use the same criteria in your advance find.
     
     
     
    <fetch distinct="true">
      <entity name="contact">
        <attribute name="contactid" />
        <attribute name="fullname" />
        <attribute name="emailaddress1" />
        
        <link-entity name="activityparty"
                     from="partyid"
                     to="contactid"
                     alias="ap">
          <attribute name="activityid" />
        </link-entity>
      </entity>
    </fetch>
     

    Filter for Specific Activity Types

     

    For example, only contacts involved in emails:

     
    <fetch distinct="true">
      <entity name="contact">
        <attribute name="fullname" />
        <link-entity name="activityparty"
                     from="partyid"
                     to="contactid">
          <link-entity name="activitypointer"
                       from="activityid"
                       to="activityid">
            <filter>
              <condition attribute="activitytypecode"
                         operator="eq"
                         value="email" />
            </filter>
          </link-entity>
        </link-entity>
      </entity>
    </fetch>
     
    let me know how you go with it. And mark it as answered if you find it helpful.

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
11manish Profile Picture

11manish 94 Super User 2026 Season 2

#2
Muhammad Shahzad Shafique Profile Picture

Muhammad Shahzad Sh... 35 Most Valuable Professional

#3
Daniyal Khaleel Profile Picture

Daniyal Khaleel 34 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans