Microsoft Power Apps Portal integration with Dynamics 365 CE On-Premise - Step By Step Guide

 Hello,


It has been quite long since I did not post any guides with you.

Today, I am going to share a PoC of mine result with detailed screenshots as much as possible. 

You will see how we can easily position Power Apps Portal in front of Dynamics 365 CRM ( CE ) Engine 9.x on-premise edition.


You are going to see following subjects in the study;

  1. Solution generation for the scenario in Dynamics 365 CRM on-premise 
    1. Create Solution
    2. Create Custom Entity
    3. Add Existing entity to a custom solution
    4. 1:N relation
    5. Form creation for Portal
    6. visibilities for portal specific fields
  2. Microsoft Common Data Service (Microsoft Dataverse) - an environment -creation
  3. Solution generation for the scenario in Dynamics 365 CRM on-premise 
  4. Microsoft Power Apps Portal creation (Starter Portal) in the environment
  5. Microsoft Dynamics 365 On-Premise customization for PoC Scenario implementation
  6. Reflecting Dynamics 365 On-Premise solution to CDS (Microsoft Dataverse) - to the environment-
  7. Aligning Microsoft Power Apps Portal with CDS customization (Power Apps Portal Web Form Steps instruction)
  8. Microsoft On-premise gateway installation and configuration
  9. Connection creation in the environment which is created above
  10. Custom Connector for Portal and Dynamics 365 CE on-premise integration (Web Api Call)
  11. Microsoft Flow data push to the Dynamics 365 CRM (CE) onpremise 

You do not need to flow all steps within an order. It is easy to jump to a section where you are stuck or looking for a solution.

Prerequisities;
  • Power Apps subscription that include Microsoft Power Apps Portal, Microsoft Flow, CDS (Microsoft Dataverse) Environment
  • Dynamics 365 on-premise up and running
  • You should have necessary access rights for Power Platform Admin Center and Dynamics 365 CRM On-Premise Organization Customization section 

Scenario:
Field service team who is not employee of organization, needs to create case in Dynamics 365 CE (CRM) on-premise.
I am going to implement turnkey solution by implementing all technolgoies that are mentioned before.

Expected operation
  • Field Service user should be able to open a form anonymously (no login to the protal)
  • Field Service user should be able to create a case with title, contact fullname, behalf Of ( keeps CRM user who is going to handle the issue )  and creates incident (custom entity which has 1-n relation with Case entity) so lookup field in case form.
High-Level Design;



Solution generation for the scenario in Dynamics 365 CRM on-premise
&
Microsoft Dynamics 365 On-Premise customization for PoC Scenario implementation 

According to the scenario, We need to create custom entities and make 1-N with out of box Case entity. It makes the PoC to cover complex entities structure displaying in PowerApps Portal Page.
  • Open Internet Explorer or Google Chrome browser
  • Type url address of Dynamics CRM On-premise organization which will be used throughout the PoC.
  • Login to Dynamics 365 CRM Onpremise

     
  • Click arrow near the Sales in the Navigation Bar. Ribbon menu will be expanded then choose Settings> Solution (Under Customization section)
  • Click +New to create new solution
  • Fill Display Name, Choose Publisher, enter Version  then click Save


  • Go to Entities TreeView Menu item and Click New for new custom entity.
  • New Pop-up windows will display, give Display Name, Plural Name and Name for the entity then tick Sales under "Areas that display this entity".
  • Click Publish


  • Go to Entities node then click "Add Existing" and find Case.
  • Select "Add All Assets" right upper top of the pop-up window after that click "Finish"


  • Go to 1:N relationships node under Entities>Incident then click "New 1-to-Many Relationship


  • Choose "Case" from "Related Entity" then fill "Display Name"

    Please payy attention Name under Relationship Definition and Name under Lookup field for some best practice.
  • Click "Save and Close" to close the window.
  • As Case form is out-of-box entity, It comes with default form which is not proper for the PoC scenario. we need to keep form sample for easy understanding so need to create new form call "Case for Portal" so
    Go to Forms node under Entities>Case>Forms then open "Case" form under Active Forms (System Forms) via double click.


  • Click "Save As" from menu


  • A pop-up window will display type "Case for Portal"  then click OK and Save & Close respectively.


  • Double Click "Case for Portal" from list to Open it again 


  • Add Incident field to the Summary tab from Field Explorer left (just drag and drop)
  • Set unnecessary fields invisible for portal : Case Title, Customer, Incident fields can be leave as visible (Sceenshot might be difference below no need to make it exactly same at your end.) 
    Double click to the field that you want to make it invisible

  • Click Ok> Save & Close to come back main Solution window
  • Click "Publish All" to apply all to the organization.
  • It is time to export the solution for CDS at Cloud ( We want to reflect the solution to the CDS in order to push data back through Microsoft Flow. Portal should keep all generated records in CDS for not CRM user view)
    Click Information leaf in the left treeview. You are going to see "Export Solution" button in the ribbon (top of the page).
  • Click Solution Export
  • Dynamics 365 CRM on-premise will open export tool wizard Click Next to the first step.


  • Next again


  • Leave radiobox selection as is (unmanaged) then click export


  • Wait until Dynamics 365 CRM onpremise engine creates package, you are going to see zip file bottom of the pop-up window once solution package is ready.


  • CLose all browsers. Dynamics 365 CRM on-premise is ready for the journey


Microsoft Common Data Service (Microsoft Dataverse) - an environment -creation

  • Connect to https://admin.powerplatform.microsoft.com/environments through browser
  • Login the PowerPlatform Admin center with your valid subscription
  • Click + New to the Environments


  • Enter a name to the environment and Click Save from the recently displayed panel on the right


  • Provisioning may take some time so wait until State column of the new environment is Ready.
  • Close all browsers
  • Environment is ready to be used for Portal.




Reflecting Dynamics 365 On-Premise solution to CDS (Microsoft Dataverse) - to the environment-

  • Connect to https://admin.powerplatform.microsoft.com/environments through browser.
  • Click to the newly created environment name .


  • Environmet detail is going to be opened.


  •  Click Environment URL to open environment . New tab is going to be opened.
     Click "Dynamics 365 - Custom" under "Published Apps"


  • Environment main page will be opened
  • Click Gear icon in from top right of the window then Advanced Settingfrom the menu


  • A form within new tab will be opened.
  • Click arrow near the Settings in the Menu then choose Solutions under Customization
  • Click New  


  • Enter Display Name, Publisher, Version then click save, Solution will be created.
  • Create Case entity with fields what we created before in Solution generation for the scenario in Dynamics 365 CRM on-premise & Microsoft Dynamics 365 On-Premise customization for PoC Scenario implementation section (The very first one) and implement instruction to environment from there.

Microsoft Power Apps Portal creation (Starter Portal) in the environment

  • Connect to PowerApps through Power Apps and login with your valid subscription
  • Make sure that you are connected to the correct environment what we created before.
  • Click "Portal from Blank" section from "make your own app"
  • Enter Name to portal and unique address (system is going to check availability - Change it where needed) then click create (portal name is an example and it will not be used in the guide anymore).


  • Portal Management (Common) and your portal apps are going to create acoordingly. it may take quite time. Please wait until provisioning are completed.

  • Continue with following section, no need to close browsers

Aligning Microsoft Power Apps Portal with CDS customization (Power Apps Portal Web Form Steps instruction)

  • Click Portal Management to open portal (you should use existing web page of the previous step)


  •  New tab will open. Active Web Sites will be displayed


  • We are going to create
    - Web Forms under "Home" Web Page under "Starter Portal" Web Sites
    - Web Forms will have "Web Forms Steps" for staging (or wizard steps implementation)
  • Go to Web Forms from Content in the left section of the window (SAM Case Form will be used in the guide so you will see form update instead of form creation in folowing steps)


  • Enter Name, choose "Starter Portal" for Website Lookup and save it. Record will be created.
  • First page of the wizard should create. We can achieve it from "Start Step" lookup.
    To do this
    Click magnifying glass then choose + New Web Form Step from drop-down menu.
    This is our Case form steps will collect incident and 1:N relations.
    We are going to create
    - Case Web Step Type of "Load Form"
    - Conditional Web Step for Next Step
    - 1:N look up selection as Load Form Type of Web Step
  • First Web Step: "Case Main Form"

  • Second Web Step: "Case Type";
    Enter a name for the step, it will display in portal as a stage
    Choose Condition as Type so Condition tab will appear
    Choose Target Entity Logical Type where we are going to use a filed from in condition tab
    Choose Next Step for the condition pass

    Click Condition Tab for station rule . Choose Condition and select Next Fail Step.



  • Third Web Step: Incdent Lookup select in Case form
    Create Web Form Step for Case entity 

    and display Portal Incident Lookup view of Case entity (It is custom form that has only Incident lookup field enabled).


  • When the Microsoft Power Apps Portal is loaded, Created records will be generated as a component by PowerApps engine.
    Main Web Step Form 

    Incident Web Step (Condition that is bound to Form Type, sets Load Form of Incident as a next Step due to Web Step Condition)


    Next Step field in Inceident Web Step will be called once user click next. It is Bind to Case Web Step

     Lookup value is selected as seen below 
    Submit saves the form to the CDS (Microsoft Dataverse) 



Microsoft On-premise gateway installation and configuration

  • Open the environment which is creted above from https://makes.powerapps.com
  • Then goto Gateways under Data
  • Click New gateway from the main section



  • You are going to be forwarded to https://powerapps.microsoft.com/en-us/downloads for On-Premise Data Gateway wizard download.
    You have to install it to a Server/PC/Laptop which is accessible for Dynamics 365 On-Premise Organization.
    Click downloaded file to start wizard and wait untill installation is completed 


  •  Sign in with an account which has proper rights on the environment. Emaill address and password need to enter

  • Choose first radio button for new registration then click Next


  • Fill gateway name and Recovery Key (any values but min 8 characters) by considering warning in the form. Click Configure for the final step




  • Choose a region or keep auto-selected value and click done

  • Wait until configuration completes, Click Close for wizard closure


  • Once the On-Premise data gateway wizard completes configuration you should be able to see Gateways in the Power Apps section of newly created environment.
    Gateway builds a highly secure bridge from cloud into local machine and Dynamics 365 CRM on-premise as well since local machine can access the local Dynmacis CRM Front End server.


  • Double click the row to see gateway detail



Connection creation & Custom Connector for Portal and Dynamics 365 CE on-premise integration (Web Api Call) 

Our scenario requires custom connector creation in order to push data to the Dynamcs 365 CRM in-premise through On-Premise Gateway. 
It is used by Microsoft flow to be triggered automatically when a case record updates. We do not set a trigger to record creation since we have a 1-N relatd entity for case that is called Incident so First step User is going to create a case record then create an incident finally bind Incident to case .

Note: I have a case creation request for Dynamics 365 CE on-premise under a Postman collection. We are going to import it as a template. 
Request :
        {
"id": "110b8796-f20e-4773-a400-969ff71a82b1",
"name": "Case Creation",
"url": "{{webapiurl}}incidents",
"description": "",
"data": [],
"dataOptions": null,
"dataMode": "raw",
"headerData": [
{
"key": "Content-Type",
"value": "application/json",
"description": "",
"type": "text",
"enabled": true
}
],
"method": "POST",
"pathVariableData": [],
"queryParams": [],
"auth": {
"type": "ntlm",
"ntlm": [
{
"key": "domain",
"value": "<hiden>"
},
{
"key": "username",
"value": "<hiden>"
},
{
"key": "password",
"value": "<hiden>"
}
]
},
"events": [],
"folder": null,
"rawModeData": "{ \r\n\t\"title\":\"First Postman Case\", \r\n\t\"customerid_contact@odata.bind\":\"/contacts(4349D8CA-2C5B-EB11-9687-000D3A98AD7F)\" \r\n}",
"headers": "Content-Type: application/json\n",
"pathVariables": {}
}

  • Go to Custom Connectors under Data node of the environment that we created before.



  •  Click to New custom connector from the right top menu of the form



  • Choose Import a Postman Collection from the menu item


  • A pop-up menu will be displayed. Enter a connector name and give postman collection path via Import button then click Continue


  •  Power Apps is going to create connector and open the main form.
    type Host as a IP address and choose http scheme
    then click Security bottom of the General Information section



  • Choose Authentication type as "Windows authentication" then click Definition

  • Enter Summary, Desctiption and OperationId like Incident Creation as a name and IncidentCreation as an Operarion ID


  • Click Create connector to save it. 
     



  • You can test it from Test tab


  • Connection will be there




Microsoft Flow data push to the Dynamics 365 CRM (CE) onpremise 

  • Go to "Flows" item from Power Apps portal for new environment


  •  Click "+ New Flow" from menu toolbar then click "Automated cloud flow"


  • Automatic cloud flow window will display.


  • Find and choose "When a records is created, ipdated or deleted" for Common Data Service (current environment) then click Create


  • Configure trigger rules with bound entity as seen below




  • Create condition for following flow;
    When case record updates, check
    • On-Premise Case ID field must be null
    • Incident lookup must have a valid value

  • in order to add condition to flow, click + New Step button
  • Choose Condition from the menu


  • Add condition


  • set first rule





  • for "No" result




  • for "yes" case




  • choose Custom for our D365 connector that we created before


  •  here is the all applied flows of "Yes" step



Hopes, it will be useful for you.
Enjoy !

Comments

Post a Comment

Popular posts from this blog

Complex Query in QueryExpression in Microsoft CRM 2011

Exception caught instantiating TERADATA report server extension SQL Reporting Services