4. 4
●About the Speaker :
Introductions
Arnab Ray
Senior Lead Engineer
Apisero
Certified Platform Architect
2+ years of Experience in Integrations
5. 5
● Both the Speaker and Hosts are organizing this meetup at individual capacity. We are not
representing our Organisations here.
● This presentation is strictly for learning purpose only.
● We do not hold any responsibility that same solution will work for your business usecase also.
● This Presentation is not meant for any promotional activities.
Safe Harbor Statement
7. 7
● Microsoft Dynamics 365 is a product line of enterprise resource planning (ERP) and customer
relationship management (CRM) intelligent business applications announced by Microsoft.
○ We’ll focus on Dynamics 365 CRM.
○ Although in the MuleSoft world, Salesforce is arguably the most common CRM (19% market share),
Microsoft Dynamics has been an emerging option for a lot of companies(3-4% market share).[Source]
Pros:
■ Integrates out of the box with the suite of Microsoft products.
■ Active Azure subscription customers are familiar with the product suite and easy maintenance.
■ Is built on top of MS-SQL server and follows similar syntaxes.
Cons:
■ Outdated and distributed documentation.
■ Very few Anypoint/MuleSoft-specific documentation/community forums/blogs available.
Introduction to Microsoft Dynamics 365
8. 8
● Tables/Objects -> Entities
○ Example: Account, Contact, Opportunity, Lead
● Fields -> Attributes
○ Example: FirstName, LastName, Email, ModifiedOn, CreatedOn
● Primary Key/Id is named based on Entity Name.
○ Example: accountid, contactid, leadid, opportunityid
○ Does not always necessarily follow <object_name> ++ ‘id’ syntax. (Example: activitypointer ->
activityid)
● Entity Sets -> Group of Entities.
○ Example: accounts (entity set of account), contacts (entity set of contact)
○ Microsoft Web API uses “entity set” terminologies. (Example: SELECT accountid FROM accounts)
● Dynamics 365 CRM documentation also refers it as Microsoft Dynamics 365 CE (Customer
Engagement) [CE refers to the on-prem setup of Dynamics 365]
● MuleSoft connector uses Microsoft Web APIs.
Terminologies/Cheat-sheet:
9. 9
● Azure Portal
○ Link: https://aad.portal.azure.com
○ Usage: To create OAuth applications, retrieve client id and secret, allow scopes.
● Dynamics 365 CRM
○ Link: https://<YOUR_INSTANCE_NAME>.crm8.dynamics.com/main.aspx
○ Usage: View records, Navigate apps.
● Microsoft 365 Admin:
○ Link: https://admin.microsoft.com/Adminportal/Home
○ Usage: Manage Subscriptions, Licenses
● Power Platform Admin:
○ Link: https://admin.powerplatform.microsoft.com/environments
○ Usage: Manage User, Manage Environments
● Power Apps
○ Link: https://make.powerapps.com/environments/<ENV_ID>/solutions/
○ Usage: Structural view of data (Equivalent to “Setup” of Salesforce). View attributes, explore API
names, create fields and relationships
Useful Links and Navigations:
10. Trial Account Setup and Navigation
Integrating Microsoft Dynamics
365 CRM with MuleSoft
11. 11
All points throughout this PPT is covered based on Web API v9.1 and MuleSoft Dynamics
365 Connector version 2.5. Some functionalities might change due to updates in the
product.
Disclaimer:
12. 12
● Create a free Microsoft Dynamics 365 Trial Account from here:
○ https://dynamics.microsoft.com/en-in/
● Login in the account.
● Select your name and select Dynamics 365 Home.
Create Trial Account
13. 13
● Inside Dynamics 365 Home, select Power Apps.
○ Link: https://www.office.com/apps?deepLink=business-apps
Power Apps
If prompted to “Create Database”, select the same and follow the next steps. This should
initialize the Sales App with all out of the box entities and sample records.
14. 14
● Microsoft Dynamics 365 CRM is divided into multiple “Solutions”.
○ A solution can contain one or more apps as well as other components such as site maps, entities,
processes, web resources, option sets, and more.
○ For our discussion, we will stick to “Default Solution”. Check with customer specific solution before
proceeding with the next steps.
Default Solution
15. 15
● Search for an entity to view all details for the specific entity.
Entity Information
16. 16
You can check the Label on Front-End and the API_Name of the entity.
Field Label and API Name
17. 17
● Unlike Salesforce, related records works differently in Microsoft Dynamics 365 CRM.
○ Example: SELECT ContactId FROM Account -> Retrieves Related Contact ID of an Account.
However, in Dynamics, the same cannot be directly queried without JOIN. (More on this later in
demo)
Relationships
18. Setup Sales App and Start Using Dynamics 365 CRM
Integrating Microsoft Dynamics
365 CRM with MuleSoft
19. 19
● Login to Power Platform Admin Center. (Note: Power Platform Admin and Power Apps are
different)
● Select Environment -> Create New Environment. Select Type=Trial for Trial account.
Create Sales App for Dynamics 365 CRM
21. 21
● Wait for Environment to spin up. Might take few mins. The page might not auto refresh, check
with manual refresh.
● Once done, select the new environment and the instance URL should be present.
Create Sales App (Continued)
22. 22
● Once logged in to the instance, select “Sales App” to get started!
Create Sales App (Continued)
30. 30
Create New Application (Continued)
● Provide Dynamics CRM Permission for the App. Verify the permission.
31. 31
Create New Application (Continued)
● Once done, set the Client ID, Client Secret and other configurations in Anypoint Studio - Dynamics
365 connector. You might still get the below even after having the all possible configuration values.
(Note: It’s 403 Forbidden and not 401)
ERROR 2022-03-05 21:56:41,566 [[MuleRuntime].uber.01: [meet-up-demo].meet-up-demoFlow.BLOCKING @1819af5e] [processor: meet-up-demoFlow/processors/1; event: 0977da00-
9ca1-11ec-b04a-3c063021f1ec] org.mule.runtime.core.internal.exception.OnErrorPropagateHandler:
********************************************************************************
Message : (0x80072560) The user is not a member of the organization. [HTTP/1.1 403 Forbidden]
Element : meet-up-demoFlow/processors/1 @ meet-up-demo:meet-up-demo.xml:20 (Retrieve multiple by query)
Element DSL : <dynamics:retrieve-multiple-by-query doc:name="Retrieve multiple by query" doc:id="0639322e-77f8-4f4d-b6dc-47a106d10858" config-
ref="Dynamics_365_Dynamics_365">
<dynamics:query>SELECT accountid FROM accounts</dynamics:query>
</dynamics:retrieve-multiple-by-query>
Error type : DYNAMICS:UNAUTHORIZED
FlowStack : at meet-up-demoFlow(meet-up-demoFlow/processors/1 @ meet-up-demo:meet-up-demo.xml:20 (Retrieve multiple by query))
(set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
********************************************************************************
32. 32
● Let’s get back to Power Platform Admin Center (not Power Apps).
● Select the appropriate environment and select “Settings”.
Create Application User
34. 34
● Select the app that was created in Azure AD in earlier steps.
● Select appropriate business unit.
● Select appropriate security role per required permission and Create.
Create Application User (Continued)
36. 36
● There are multiple Microsoft 365 Connectors available in Exchange.
● We will be using the 365 connector (not the CRM connector).
Download Connector in Anypoint Studio
37. 37
● Endpoint: Your instance URL from Power
platform admin center -> Environment.
● Proxy: Optional.
● Client ID: From Azure AD.
● Client Secret: From Azure AD.
● Token URL:
https://login.microsoftonline.com/<tenant_id>/oa
uth2/v2.0/token
○ Tenant ID: From Azure AD.
● Scopes:
○ <Endpoint> ++ “/.default”
Configure OAuth Credentials Obtained
40. 40
● Retrieve Multiple By Query uses DSQL (Datasense Query Language) which is limited in
scope but easy for quick development.
● Retrieve Multiple uses Web API URL. The same URL can be copy-pasted to and from
Postman(or any Rest Client) and Studio.
● Web API Documentation: https://docs.microsoft.com/en-us/powerapps/developer/data-
platform/webapi/query-data-web-api
● Documentation on a per Entity basis(Attributes, Operations, Restrictions, etc.):
https://docs.microsoft.com/en-us/dynamics365/customerengagement/on-
premises/developer/about-entity-reference?view=op-9-1
● Audit Entity: https://docs.microsoft.com/en-us/dynamics365/customer-engagement/web-
api/audit?view=dynamics-ce-odata-9
● Any lookup field which is supposed to be a part of $expand parameter, if mistakenly provided
in $select, does not raise any error and is silently dropped from the response.
● MDynamics 365 CRM might return unwanted fields in the response even if not provided in
either $select or $expand. This might break 1:1 synchronization integrations and has to be
taken care of.
Things to Remember
41. 41
● Any deletion of record in MDynamics 365 CRM is a hard-delete and no flag(Ex: IsDeleted for
Salesforce) is maintained. To retrieve deleted records, enabling Audit and Querying Audit is
an alternative.
Things to Remember (Continued)
44. 44
● Share:
○ Share using the hashtag #MuleSoftMeetups
○ https://meetups.mulesoft.com/indore/
● Feedback:
○ Fill out the survey feedback and suggest topics for upcoming events
○ Contact MuleSoft at meetups@mulesoft.com for ways to improve the program
○ You can contact us directly at indoremulesoftmeetup@gmail.com.
What’s next?