To code simply you must master complexity and break it down to it’s simpliest form #HoskCodeWisdom
Fools ignore complexity. Pragmatists suffer it. Some can avoid it. Geniuses remove it. Alan Perlis
Junior developers create many lines of code and complexity, senior developers then remove lines of code and simplify #HoskCodeWisdom
The ActivityParty entity catches many new Dynamics 365/CRM developers by surprise because it’s an entity inside an entity. This blog post looks at ActivityParty and some great resources to help you conquer it.
To spice up CRM development Microsoft likes to throw in a few special entities that have special powers. Microsoft have created great documentation but then littered it around so it’s hard to piece all the useful bits together.
- Customers (which can hold accounts and contacts)
- ActivityParty (can hold any of the activity types)
- regarding (can hold any object)
- Owner – it can be a user or a team
- Address entity, it’s half on the account, contact form but you can see it in advanced finds
I got an odd error once with ActivityParty and casting
The ActivityParty is complex record, its important to understand how it’s linked to Activities, Microsoft have some excellent documentation here
This picture quickly summaries ActivityParty
Richard Knudson has a great blog post on ActivityParties
First step go to the MDSN definition
An activity party represents a person or group associated with an activity. An activity can have multiple activity parties.
Where are party lists used? The most common area in CRM Activity Party is used is the To and From on an email. The reason the ActivityParty is used is because an email can have multiple email addresses in the TO, CC (it’s a party of people)
Email is a easy way to understand not only how Activity Lists work but why we need them. The TO field on an email might contain multiple email addresses.
It also explains the name, each person on an email is an activity party and an activity party is a person or group.
As mentioned before an ActivityParty entity can hold many different entities, to see what type it is you need to check the Activity Party Type
There are 11 activity party types in Microsoft Dynamics 365. The different types are identified by the a different int value as shown below from MSDN documentation.
|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.|
- phone calls
The following table lists the activity party types that are supported for each activity, and the corresponding activity properties to specify those activity party types. ActivityParty entity
|Activity entity name||Supported activity party type||Activity attribute|
Reading a Resource
List<ActivityParty> resources = (List<ActivityParty >)serviceAppointment.Resources.ToList();
- To learn more about activity party read this article by Richard Knudson
- working with ActivityParties
- Dynamics special data types
- Entity.GetAttributeValue<T> and ActivityParty