We will understand the concept of an Activity Party in Dynamics 365 / Power Apps. Before we start, make sure to subscribe to CRM Crate so that you can stay up to date in the field of Power Apps.
What is an Activity Party in D365 / Power Apps?
An Activity Party is a special entity / table which is used to store the parties associated with any activity type. It represents a person or group associated with an activity. An activity can have multiple activity parties.
Below are the different types of parties and their significance.
Activity party type | Value | Description |
---|---|---|
Sender | 1 | Specifies the sender. |
ToRecipient | 2 | Specifies the recipient in the To field. |
CCRecipient | 3 | Specifies the recipient in the Cc field. |
BccRecipient | 4 | Specifies the recipient in the Bcc field. |
RequiredAttendee | 5 | Specifies a required attendee. |
OptionalAttendee | 6 | Specifies an optional attendee. |
Organizer | 7 | Specifies the activity organizer. |
Regarding | 8 | Specifies the regarding item. |
Owner | 9 | Specifies the activity owner. |
Resource | 10 | Specifies a resource. |
Customer | 11 | Specifies a customer. |
Not all types are available for each activity in Dynamics 365 for Customer Engagement, except for a custom activity. Below is the list of activity party types that are supported for each out of the box activity, and the corresponding activity properties to specify those activity party types.
Activity entity name | Supported activity party type | Activity attribute |
---|---|---|
Appointment | OptionalAttendee Organizer RequiredAttendee | Appointment.OptionalAttendees Appointment.Organizer Appointment.RequiredAttendees |
CampaignActivity | Sender | CampaignActivity.Partners CampaignActivity.From |
CampaignResponse | Customer | CampaignResponse.Customer CampaignResponse.Partner CampaignResponse.From |
BccRecipient CcRecipient Sender ToRecipient | Email.Bcc Email.Cc Email.From Email.To | |
Fax | Sender ToRecipient | Fax.From Fax.To |
Letter | BccRecipient Sender ToRecipient | Letter.Bcc Letter.From Letter.To |
PhoneCall | Sender ToRecipient | PhoneCall.From PhoneCall.To |
RecurringAppointmentMaster | OptionalAttendee Organizer RequiredAttendee | RecurringAppointmentMaster.OptionalAttendees RecurringAppointmentMaster.Organizer RecurringAppointmentMaster.RequiredAttendees |
ServiceAppointment | Customer Resource | ServiceAppointment.Customers ServiceAppointment.Resources |
Method for reading / getting parties using JavaScript
We will build a Web API query “retrieveMultipleRecords” for retrieving the value from a party. Below are the list of parameters required in our query.
Parameter Name | Parameter Value |
activityId | This will be the unique identified or GUID of the Activity record (letter/email/phone call etc.) |
participationtypemask | This value can be selected as per the type of activity party as shown in the above table |
partyId | This will be the GUID of the primary entity which is associated with the activity entity |
Below is the Web API Query build using the above details.
(async (entityId)=>{
const activityEntity=await Xrm.Web API.retrieveMultipleRecords("activityparty", "?$filter=_activityid_value eq " +
entityId + " and participationtypemask eq 2&$select=_partyid_value,_activityid_value");
activityEntity.entities
.map(x => ({
id: x._partyid_value,
entityLogicalName: x['_partyid_value@Microsoft.Dynamics.CRM.lookuplogicalname'],
Name: x['_partyid_value@OData.Community.Display.V1.FormattedValue']}))
.forEach(console.log);
}
)('Your entity ID');
The above JavaScript snippet will provide the below given output –
1. 0: {id: "fa8c129e-31b4-e911-a99d-000d3ab34f96", entityLogicalName: "account", Name: "Prashant Tirlotkar"} 2. 1: {id: "0f2ba5cd-35b4-e911-a996-000d3ab311g9", entityLogicalName: "contact", Name: "Omkar Rane"} 3. 2: {id: "7ca6600e-3cb4-e911-a99d-000d3ab31f4r", entityLogicalName: "contact", Name: "Priya Gupta"}
Thus, we learned the significance of an Activity Party entity and a way to retrieve its data.