25) Dynamics 365 for Finance and Operations File Based Recurring Integration Using DMF and Logic Apps

File based recurring integration is the most common way to make integrations between an ERP and other transactional systems.
Azure Logic Apps is a cloud service that helps you schedule, automate, and orchestrate tasks, business processes, and workflows when you need to integrate apps, data, systems, and services across enterprises or organizations.
In this typical business scenario for Dynamics 365FO  integrations, data will be exported to a downstream system on a recurring schedule. This blog post shows how to export a data package and save it to a OneDrive shared folder.
Scenario:
Contoso Entertainment System USA needs to provide a daily Expense report for all of its employees travel expenses to their Payroll service provider.

Create a New Export Job

In this step, you will be creating a new export job that can be used to export the Expenses entity:
  • Navigate to Workspaces > Data management.
  • Click on the Export
  • Fill out the Export details
    1. In the Group name field, type ExpensesExport.
    2. In the Description field, type Expenses export.
    3. Click Add entity, then type Expenses. For the Target data format, select CSV then click Add.

Create a new Logic Apps

  1. Sign into Azure portal
  1. Select Create a resource > Logic Apps > Create

 

3. Select a Resource Group, write down a Logic App Name and click on Review+Create
4. On the Logic App page select the Logic app designer option and then select Blank Logic App
5. Search for Recurrenceand select the Trigger.
6. Select the Interval and the FrequencyAdd new parameter Time zone and at these hours
7. Add a +New step and search for Initialize variable
8. In this variable we will store the batch job execution ID
9. Add a +New step and search for Until
10. Before you add a value to control the loop, Add an action: 
11. Search for Dynamics 365 for fin. In Actions select Execute action
12. Sign in to create a connection to Dynamics 365 for Fin & Ops.
13. Select your environment instance. In Action select DataManagementDefinitionGroups-ExportToPackage. This is the action that will execute the export Batch Job that we created earlier. Rename Execution action to ‘ExecuteBatchJob’
14. Now you can add a value to control the loop. On ‘Choose a value’ text field and select OutputParameters is not equal to 00000000-0000-0000-0000-000000000000.
15. Add few parameters.
  • definitionGroupId = ExpensesExport (this is the name of the export Batch Job created in D365FO.
  • executionID = Initialize variable BatchJobID
  • reExecute = No
  • legalEntityID = USMF (select the same legal entity where you created the export Batch Job).
16. Add an action and search for This delay is intended to allow D365FO to post the job results after it has finished.
17. Add a +New step and search for Condition
18. Now define the condition. If value is-equal-to BatchJobID. The Value output parameters will contain the same execution ID that we provided while calling the execution action.
19. The false condition indicates that the package can’t be exported. We will send an email with the message. Add an action and search for Send an email (V2):
20. Sign in with your Outlook credentials and include the email information:
21. Add an action for the True condition. Search for Dynamics 365 for fin. In Actions select Execute action.
22. In the Action field select DataManagementDefinitionGroups-GetExportedPackageUrl. Finally add a new parameter (executionId) and add the value of the ExecuteBatchJob
23. Add an action, search for HTTP, and select HTTP again in the Actions section 
24. Set the Method to Get and URI as output value of the execute action added in step
25. Add action to create a file on OneDrive. Look for OneDrive in the action search box. Select OneDrive and then select Create file action
26.Sing in with your OneDrive credentials and provide the following information:
Folder path = /Integration
Create a new folder on your OneDrive
File Name = Expenses.zip
The zip extension is the default extensions of the data packages
File Content = Body
You need to provide the Body of the HTTP action form the earlier step.
27. Add an action and search for Send an email (V2). Include the confirmation information about the Expense package.
28. Save the Logic App. The Flow should look like this
29. Run the Logic App
30. Go back to the D365FO portal and review the Job history in the Data management workspace. A new export job with the name ExpensesExport should be executed 
31.On the Azure portal, review if the Logic App executed successfully 
32.Finally go to your OneDrive to find the Expenses.zip data package

Comments

Popular posts from this blog

Customization on Sales invoice Report in D365 F&O

75) COC - Create a coc of the table modified method

46) D365 FO: SHAREPOINT FILE UPLOAD USING X++