There’s quite a few integration services around that will sync Eventbrite data into your Dynamics 365 organisation and I’ve found that they can be quite expensive. A recent project called for us to get a little creative and find a cheaper alternative – that’s where Microsoft Flow comes in!
What can it do?
Using Microsoft Flow we can achieve the following:
- Sync new Eventbrite events into Dynamics 365
- Sync new Eventbrite registrations into Dynamics 365
- Sync Eventbrite registration updates into Dynamics 365
-
- I.e. Cancellations, email or name changes
-
One limitation it has at the moment is that updates to events are not picked up as there’s no trigger in Microsoft Flow for this action. It’s a small price to pay when comparing the costs to the other integration options. Microsoft are always adding new features and connections to Flow each month, so who knows it may be available soon. I get around this by displaying the actual Eventbrite event in an iFrame on the form.
The only other drawback is that a new Flow needs to be configured for each new event so that registrations are captured in Dynamics 365. This is an easy process, as it’s done by cloning an existing Flow and tweaking it to point to the new event. So all in all, it adds maybe 5 minutes to the event creating process.
Microsoft Flow Licensing
Since Eventbrite is a premium Microsoft Flow connection, a Premium license is required to setup this integration. The great thing is if you already have a Dynamics 365 Enterprise license (including Sales or Service Enterprise), then Microsoft Flow Premium is already included – so no need for an extra license!
Summary
At a high-level I’ll step you through the following changes to get the integration between Eventbrite and Dynamics 365 working:
- Create the event and event registration entities in Dynamics 365
- Create a Dynamics plugin to create / update a Dynamics 365 lead or contact based on new event registrations
- Create 2 Microsoft Flows to manage syncing Eventbrite event and registration data
Dynamics 365 Structure
Create the following 2 new entities within Dynamics 365 to represent the event and the event registration:
Event:
Name: Event
Schema Name: new_event
Attributes:
Column Name | Schema Name | Type | Size |
---|---|---|---|
Name | new_name | Single line of text | 512 |
Start Date | new_startdate | Date and Time | |
End Date | new_enddate | Date and Time | |
Eventbrite URL | new_eventbriteurl | Single line of text | 512 |
Description | new_description | Multiple lines of text | 2000 |
Eventbrite ID | new_eventbriteid | Single line of text | 50 |
Event Registration:
Name: Event Registration
Schema Name: new_eventregistration
Attributes:
Column Name | Schema Name | Type | Size |
---|---|---|---|
First Name | new_firstname | Single line of text | 100 |
Last Name | new_lastname | Single line of text | 150 |
new_email | Single line of text | 300 | |
Registration Status | new_registrationstatus | Optionset: - Registered (default) - Attended - Cancelled | |
EventBrite Status | new_eventbritestatus | Single line of text | 20 |
Eventbrite ID | new_eventbriteid | Single line of text | 20 |
Note: all but the Eventbrite Status field are shown on the form. The Eventbrite Status is used behind the scenes by the plugin to translate the passed Eventbrite status to the Registration Status optionset. Eventbrite will pass either of the following values:
- placed = Registered
- refunded = Cancelled
Relationships:
Add 3 new many to one (N:1) relationships:
- Event:
Lookup field display name: Event
Lookup field name: new_eventid
- Lead:
Lookup field display name: Lead
Lookup field name: new_leadid
- Contact:
Lookup field display name: Contact
Lookup field name: new_contactid
Dynamics 365 Plugin
The primary use of the plugin is to search Dynamics 365 using the registration email address for a lead or contact. If a record is found, then it attaches the registration to it, otherwise it will create a new lead record and attach the registration to it.
This could have been achieved within Microsoft Flow by adding “Dynamics 365 list records” step, however I prefer the flexibility of a plugin. It allows me to add extra search or create record logic that would be above and beyond MS Flow’s capabilities.
Plugin Code
Use the following code to create the new plugin (feel free to tweak the logic as needed).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 |
public void Execute(System.IServiceProvider oServiceProvider) { /*************************************************************************** 'Purpose: Manage Event Registrations 'Triggered: Pre Create / Update Event Registration '***************************************************************************/ IPluginExecutionContext oContext = ((IPluginExecutionContext)(oServiceProvider.GetService(typeof(IPluginExecutionContext)))); IOrganizationService oServiceProxy; Entity oPassedEntity; Entity oPreImage; string sContactId = ""; string sLeadID = ""; string sFirstName = ""; string sLastName = ""; bool bUpdateName = false; try { // Setup the service: IOrganizationServiceFactory oServiceFactory = ((IOrganizationServiceFactory)(oServiceProvider.GetService(typeof(IOrganizationServiceFactory)))); oServiceProxy = oServiceFactory.CreateOrganizationService(oContext.UserId); // Ensure it's an event registration (new_eventregistration): if (oContext.InputParameters.Contains("Target") && oContext.InputParameters["Target"] is Entity) { oPassedEntity = (Entity)oContext.InputParameters["Target"]; if ((oPassedEntity.LogicalName != "new_eventregistration")) { return; } } else { return; } //Check for a name update: if (oPassedEntity.Attributes.Contains("new_name") == false) { bUpdateName = true; } else { if (oPassedEntity["new_name"] == null) { bUpdateName = true; } } if (bUpdateName == true) { if (oPassedEntity.Contains("new_firstname") == true) { sFirstName = oPassedEntity["new_firstname"].ToString(); } if (oPassedEntity.Contains("new_lastname") == true) { sLastName = oPassedEntity["new_lastname"].ToString(); } oPassedEntity["new_name"] = sFirstName + " " + sLastName; } //Check for a email update: if (oPassedEntity.Attributes.Contains("new_email") == true) { //See if a contact exists with the email: sContactId = fn_FindContact(oPassedEntity["new_email"].ToString(), ref oServiceProxy); if (sContactId.Length > 0) { EntityReference oContactRef = new EntityReference("contact", new Guid(sContactId)); oPassedEntity["new_contactid"] = oContactRef; } else { sLeadID = fn_FindLead(oPassedEntity["new_email"].ToString(), ref oServiceProxy); if (sLeadID.Length > 0) { EntityReference oLeadRef = new EntityReference("lead", new Guid(sLeadID)); oPassedEntity["new_leadid"] = oLeadRef; } else { //Create a new Lead: Entity oLead = new Entity("lead"); if (oContext.MessageName == "Update") { oPreImage = (Entity)oContext.PreEntityImages["PreImage"]; if (oPassedEntity.Contains("new_firstname") == true) { sFirstName = oPassedEntity["new_firstname"].ToString(); } else if (oPreImage.Contains("new_firstname") == true) { sFirstName = oPreImage["new_firstname"].ToString(); } if (oPassedEntity.Contains("new_lastname") == true) { sLastName = oPassedEntity["new_lastname"].ToString(); } else if (oPreImage.Contains("new_lastname") == true) { sLastName = oPreImage["new_lastname"].ToString(); } } else { if (oPassedEntity.Contains("new_firstname") == true) { sFirstName = oPassedEntity["new_firstname"].ToString(); } if (oPassedEntity.Contains("new_lastname") == true) { sLastName = oPassedEntity["new_lastname"].ToString(); } } oLead["firstname"] = sFirstName; oLead["lastname"] = sLastName; oLead["emailaddress1"] = oPassedEntity["new_email"].ToString(); sLeadID = oServiceProxy.Create(oLead).ToString(); } //Link the event registration to either the lead or contact (depending on what was found above): if (sContactId.Length > 0) { EntityReference oContactRef = new EntityReference("contact", new Guid(sContactId)); oPassedEntity["new_contactid"] = oContactRef; } else if(sLeadID.Length > 0) { EntityReference oLeadRef = new EntityReference("lead", new Guid(sLeadID)); oPassedEntity["new_leadid"] = oLeadRef; } } } //Update Status: if (oPassedEntity.Attributes.Contains("new_eventbritestatus") == true) { if (oPassedEntity["new_eventbritestatus"].ToString().ToLower() == "placed") { //Registered: oPassedEntity["new_registrationstatus"] = new OptionSetValue(100000000); } else if (oPassedEntity["new_eventbritestatus"].ToString().ToLower() == "refunded") { //Cancelled: oPassedEntity["new_registrationstatus"] = new OptionSetValue(100000002); } } } catch (Exception ex) { throw new InvalidPluginExecutionException("Event Registration Plugin Error - " + ex.ToString()); } } private string fn_FindContact(string sEmail, ref IOrganizationService oService) { try { QueryExpression oQuery = new QueryExpression("contact") { ColumnSet = new ColumnSet("contactid") }; oQuery.Criteria.AddCondition(new ConditionExpression("emailaddress1", ConditionOperator.Equal, sEmail)); oQuery.Criteria.FilterOperator = LogicalOperator.And; EntityCollection oReccords = oService.RetrieveMultiple(oQuery); foreach (Entity oContact in oReccords.Entities) { return oContact.Id.ToString(); } return ""; } catch(Exception ex) { return ""; throw new InvalidPluginExecutionException("Event Registration Plugin Error - fn_FindContact - " + ex.ToString()); } } private string fn_FindLead(string sEmail, ref IOrganizationService oService) { try { QueryExpression oQuery = new QueryExpression("lead") { ColumnSet = new ColumnSet("leadid") }; oQuery.Criteria.AddCondition(new ConditionExpression("emailaddress1", ConditionOperator.Equal, sEmail)); oQuery.Criteria.AddCondition(new ConditionExpression("statuscode", ConditionOperator.Equal, 0)); //Active only oQuery.Criteria.FilterOperator = LogicalOperator.And; EntityCollection oReccords = oService.RetrieveMultiple(oQuery); foreach (Entity oLeadRecord in oReccords.Entities) { return oLeadRecord.Id.ToString(); } return ""; } catch (Exception ex) { return ""; throw new InvalidPluginExecutionException("Event Registration Plugin Error - fn_FindLead - " + ex.ToString()); } } |
Register Plugin
Register the plugin and setup the following steps:
Step 1
Message: Create
Primary Entity: new_eventregistration
Execution Stage: PreOperation
Step 2
Message: Update
Primary Entity: new_eventregistration
Filtering Attributes: new_email, new_eventbritestatus
Execution Stage: PreOperation
Image:
Create a new Pre Image against this step named PreImage with the following parameters:
- new_firstname
- new_lastname
Microsoft Flow
Now that the required components are setup within Dynamics 365 it’s time to setup a new Microsoft Flow to integration Event information from Eventbrite into Dynamics 365.
There’s at least 2 Flows that need to be configured:
1. Create an Event in Dynamics 365 when a new Event is created in Eventbrite
This first flow will integrate event data into Dynamics 365:
- Log into Microsoft Flow: https://flow.microsoft.com/en-us/
- Select My Flows in the toolbar
- Select + Create from blank
- Select the “Search hundreds of connectors and triggers” box and search for Eventbrite
- Select the Eventbrite – When an event is created trigger
- It will prompt to create a connection to Eventbrite, click Sign in
- A new window will open, enter your Eventbrite login Email address and click Get Started
- Enter your Eventbrite password and click Log in
- Click Allow to give Microsoft Flow access to Eventbrite data
- Now the connection is configured, back in the new Flow select the Eventbrite Organizer from the drop down.
- Select + New step and Add an action
- In the search box type “Dynamics 365″ and select Dynamics 365 – Create a new record
- If your current Flow user account has a Dynamics user license, it will log into Dynamics 365 automatically. If not, click Connect and set up the connection.
- Select the Dynamics 365 Organization Name and Events from within the Entity Name drop down
- Click Show advanced options to view all available fields to map
- Map the following fields by placing the cursor into the field within the Create a new record task and selecting it from the Eventbrite mapping:
- Name = Name
- Description = Description
- End Date = End UTC
- Eventbrite ID = Id
- Eventbrite URL = URL
- Start Date = Start UTC
The mapping should look like the screenshot below:
Note: I recommend using the UTC date fields, that way the correct date and time is recorded in Dynamics 365.
- Update the name of the flow to something more meaningful by selecting the title of the Flow in the top left just under the toolbar. I’m changing mine to When an Eventbrite event is created -> Create a new Dynamics 365 Event
- Click Save
Test the Flow
Now you have created the flow, head over to Eventbrite and create a new Event. Once that’s done, head back into Microsoft Flow, select the newly created Flow and look at the run history below – if all went well you should see a step with a status of Succeeded:
Note: this can take up to 10 minutes.
Once it’s succeeded, check in Dynamics 365 and you should have your first newly created Event.
2. Create or Update an Event Registration in Dynamics 365 when an Eventbrite registration is created or updated
This is the flow we need to create specifically for each event in Eventbrite. As I previously mentioned, once it’s in place, it’s easy to clone and point it to a new Eventbrite event.
Please ensure there’s an Event already in place within Eventbrite before proceeding with this step.
- Log into Microsoft Flow: https://flow.microsoft.com/en-us/
- Select My Flows in the toolbar
- Select + Create from blank
- Select the “Search hundreds of connectors and triggers” box and search for Eventbrite
- Select the Eventbrite – When an order changes trigger
- In the Event drop down select the event the Flow will monitor. In my case below, I’ll use my event called “Test Event”
- Click + New step and Add an action
- In the search box type “Dynamics 365″ and select Dynamics 365 – Get record
- Select the Organisation Name and the Entity Name of Events and enter the ID of the event created in the previous Flow.
This step gets the event record from Dynamics 365, which will be used later in the flow.
To get the ID, open the event within Dynamics 365 and click the Email a link tool bar button and grab the id from ti URL.
Here’s what it should look like so far:
The next step is to check to see if the registration already exists in Dynamics 365 using the Eventbrite registration ID:
- Select + New step and Add an action
- In the search box type “Dynamics 365″ and select Dynamics 365 – List records
- Select the Organisation Name and set the Entity Name of Event Registrations.
- Click Show advanced options
- Enter the following:
- Filter Query = new_eventbriteid = ‘<Eventbrite ID from Dynamic content>’
- Top Count = 1
Note: to get <Eventbrite ID from Dynamic content> scroll down towards the bottom of the dynamic content window.
The next step is to check to see if any results were returned from the List records query by using a Condition
- Select + New step and Add a condition
- Click Edit in advanced mode
- Paste the following into the condition:
@empty(body(‘List_records’)?[‘value’])
This condition checks to see if the results are empty, if it’s true (Yes), then we will create a new Event Registration record, otherwise if a record is found (No), we will update the existing record:
- In the green Yes box click Add an action
- In the search box type “Dynamics 365″ and select Dynamics 365 – Create a new record
- Select the Organisation Name and the Entity Name of Event Registrations.
- Select Show advanced options and use the following mapping from the Eventbrite fields:
- Name = Name
- Email = Email
- Event = Event (from the Get record task)
- Eventbrite ID = Id
- Eventbrite Status = Status
- First Name = First Name
- Last Name = Last Name
The mapping should look like this:
- In the red No box click …More and select Add an apply to each
- Within the Select an output from previous steps text box select value from the List records task.
- Within the Apply to each task click + Add action
- In the search box type “Dynamics 365″ and select Dynamics 365 – Update a record
- Select the Organisation Name and the Entity Name of Event Registrations.
- Set the Record Identifier to Event Registration (from List Records)
- Select Show advanced options and use the following mapping from the Eventbrite fields:
- Name = Name
- Email = Email
- Eventbrite Status = Status
- First Name = First Name
- Last Name = Last Name
The mapping should look like this:
- Now to give the flow a meaningful name, remember that this flow is specific for the event named “Test”, so I’ll name it “Test Event Registrations” by clicking the Flow name in the top left (next to the arrow):
And you’re done! The overall flow should look like this: