Dynamics - How to get all appointments that for a specific user attends by Web Api

298 views Asked by At

In Dynamics CRM, I'm trying to get all the appointments where a specific user is an attendee, using Web API. I know that I have to deal with Appointment entity and ActivityParty with activitypartytypemask equals 9 but really cannot figure out how to make it. How can identify the attendee ?

1

There are 1 answers

0
Andrew Butenko On

You can use FetchXml for your purpose. Check following Fetch:

<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="true">
  <entity name="appointment">
    <attribute name="subject" />
    <attribute name="statecode" />
    <attribute name="scheduledstart" />
    <attribute name="scheduledend" />
    <attribute name="regardingobjectid" />
    <attribute name="activityid" />
    <link-entity name="activityparty" from="activityid" to="activityid" alias="aa">
      <filter type="and">
        <condition attribute="participationtypemask" operator="in">
          <value>6</value>
          <value>5</value>
        </condition>
        <condition attribute="partyid" operator="eq" value="{9CE2BF21-408B-E611-80F3-C4346BAC7ABC}" />
      </filter>
    </link-entity>
  </entity>
</fetch>

Using provided FetchXml and WebApi you should get the result you wanted. Url should look like following:

[Server Base Url]/api/data/v8.2/appointments?fetchXml=%3Cfetch%20version%3D%221.0%22%20output-format%3D%22xml-platform%22%20mapping%3D%22logical%22%20distinct%3D%22true%22%3E%3Centity%20name%3D%22appointment%22%3E%3Cattribute%20name%3D%22subject%22%20%2F%3E%3Cattribute%20name%3D%22statecode%22%20%2F%3E%3Cattribute%20name%3D%22scheduledstart%22%20%2F%3E%3Cattribute%20name%3D%22scheduledend%22%20%2F%3E%3Cattribute%20name%3D%22regardingobjectid%22%20%2F%3E%3Cattribute%20name%3D%22activityid%22%20%2F%3E%3Clink-entity%20name%3D%22activityparty%22%20from%3D%22activityid%22%20to%3D%22activityid%22%20alias%3D%22aa%22%3E%3Cfilter%20type%3D%22and%22%3E%3Ccondition%20attribute%3D%22participationtypemask%22%20operator%3D%22in%22%3E%3Cvalue%3E6%3C%2Fvalue%3E%3Cvalue%3E5%3C%2Fvalue%3E%3C%2Fcondition%3E%3Ccondition%20attribute%3D%22partyid%22%20operator%3D%22eq%22%20value%3D%22%7B9CE2BF21-408B-E611-80F3-C4346BAC7ABC%7D%22%20%2F%3E%3C%2Ffilter%3E%3C%2Flink-entity%3E%3C%2Fentity%3E%3C%2Ffetch%3E

This article contains additional details.