| Syed Junaid
So, we all know that Microsoft Default Import Tool does not allow us to import Multiselect Choices. It also does not allow us to import Party List. So, the problem of importing Activities records that includes Multiple Activity Parties arise. Before we dive in, we should have an idea of Activity, Activity Party and Party List. So, let's get started.
What is an Activity, Activity Party and Activity Party List?
- Activities are the actions that a user does in Dynamics 365. It is used to keep track of all your communication with customers. There are several different types of Activities. Some most used activities are Appointment, Phone Call, Email, Task and Letter.
- Activity Party List is a special kind of lookup field which refers to multiple entities. I can have multiple entity references. When an Activity is created for instance, we created an activity of type Email, there would be participants in fields like To, CC, BCC. These participant types (To, CC, BCC) are known as Activity Party. An activity party represents a person, or a group associated with that activity. Activity can have multiple activities parties. To set an activity party we have to provide.
-
1. ParticipationTypeMask: It is an integer which shows which Activity Party the record belongs to. Following are the types of Activity Parties and values of ParticipationTypeMask
- a. Sender (Specifies the sender): 1
- b. ToRecipient (Specifies the recipient in the To field): 2
- c. CCRecipient (Specifies the recipient in the Cc field): 3
- d. BccRecipient (Specifies the recipient in the Bcc field): 4
- e. RequiredAttendee (Specifies a required attendee): 5
- f. OptionalAttendee (Specifies an optional attendee): 6
- g. Organizer (Specifies the activity organizer): 7
- h. Regarding (Specifies the regarding item): 8
- i. Owner (Specifies the activity owner): 9
- j. Resource (Specifies a resource): 10
- k. Customer (Specifies a customer): 11
-
2. partyid_entityname@odata.bind:
It is a entity reference that we have to give in order to assign that reference to Activity Party
So for example if I want to set a contact in To Recipient of an activity I can do it like this:
{
"participationtypemask": 2,
"partyid_contact@odata.bind": "/contacts("05f59e40-79c7-eb11-bacc-000d3a16f0c4")
}
Similarly If I want to assign multiple contacts in To Recipient (ParticipationTypeMask: 2) and multiple contacts in CC Recipient (ParticipationTypeMask: 3) I can do it by making it an array.
[
{
"participationtypemask": 2,
"partyid_contact@odata.bind": "/contacts("05f59e40-79c7-eb11-bacc-000d3a16f0c4")
},
{
"participationtypemask": 2,
"partyid_contact@odata.bind": "/contacts("d8e4f418-8e8d-eb11-a812-000d3a9b59a0")
},
{
"participationtypemask": 3,
"partyid_contact@odata.bind": "/contacts("05f59e40-79c7-eb11-bacc-000d3a16f0c4")
},
{
"participationtypemask": 3,
"partyid_contact@odata.bind": "/contacts("d8e4f418-8e8d-eb11-a812-000d3a9b59a0")
}
]
Now we can walk through one of the solutions for the problem which was to import Activities that contain multiple participants. So for achieving this these are the following steps that we need to follow:- Create temporary fields of activity parties of type text on the table we want to run our import. For instance if we want to run our import on an email entity we can create new fields of type text for toparticipant, fromparticipant and so on according to the requirement.
-
Create a Cloud Flow with the trigger on Creation of Email Messages.
-
In the flow split that text field be “;” using split formula and save it in the variable of type array. By doing this we have all the names of the participants of To Recipients.
split(triggerOutputs()?['body/temptoparticipants'], ';') -
Run for-each loop on that array and find it in the respective entity. For example if it can be a contact or it can be a user. Now we have the respective records.
Note: Create Current To Participant As String Variable
trim(variables('Current To Participant')) -
After getting the contact now we have to assign it to the Activity Party.
Note: Create PartylistBody variable of type Array -
By this step you will have all activity party recipients of To Fields in the partylistBody variable. Now we can assign it to that email message which triggered the flow.
- Now activate the flow and run the import and remember to map the data of To, From fields to those text fields we just created in Step 1.
- Turn Off the flow once import is done
By following these steps we can import Activities which use multiple activity parties using the default import tool and power automate. We can also have parallel branches for Bcc Recipients, CC Recipients with the same logic in the flow to cater our business needs.
Click here to learn more about Imperium's Dynamics Services.