Sample Logic app using Recurring integration in D365 fo

 Often we need to create data in D365 environment from a 3rd party system. Here this is basic logic app that can help to creates the data by taking the files from SFTP folder and and Creates data in d365.


1. In my case Im taking the trigger point as Recurrence as it should process the files at time on each end of the day. you can also take when file is added.












2. Take the next step and add the scope. our operations will be go on inside the scope as we can determine the logic app run process weather it is failed succeed aborted.








3. Now take the List files in the folder step from SFTP-SSH, this action will retrieve all the files from the specified folder.









4. Now take a for_each loop which will loop the each file which we will get the list in the above step. Pass body of the above step as the input for the for each loop. Add the action Get files content to read the content of the file.













You can take the file content below.



4. Now pass the file content to D365 by using the recurring integration API.  To know more about the RI please visit y blog here.
5. To connect to the D365 we would required a Tenet ID, Client Id, Client secret for the authentication.
for this step I'm creating one more global logic app with HTTP trigger which is used to get trigger the file to D365. because we can not take the request action inside a for_each loop.
6. For the logic app am taking the inputs as below.
{
    "properties": {
        "Audience": {
            "type": "string"
        },
        "CSVInputRequest": {
            "type": "string"
        },
        "InputRequestType": {
            "type": "string"
        },
        "JsonInputRequest": {
            "type": "object"
        },
        "Method": {
            "type": "string"
        },
        "URI": {
            "type": "string"
        }
    },
    "required": [
        "URI"
    ],
    "type": "object"
}
7. with The above inputs we need to create a below step for the web request.




8. Now from the above step we will get the failure and success response as below. 

9. Now go to original app and call the above created logic app and pass the inputs as below.

10. From the above you will get the respose with a message ID. To get the processing status of message queue I have added the below step. take the delay of 3 mins.

11. Now take Until step to get any one of  status added in the condition.

@or(equals(body('GetMessageStatus')?['value'], 'Processed'),equals(body('GetMessageStatus')?['value'], 'ProcessedWithErrors'),equals(body('GetMessageStatus')?['value'], 'PostProcessingError'),equals(body('GetMessageStatus')?['value'], 'PreProcessingError'))









12. Now trigger the getMessagestatus API by using the above created gobal logic app.

13. if it is processed we need to move this to Archive file.


14. if the status other than this we need to move this to error folder.



Follow the process step by step for any host-to-host integration using Logic Apps. Feel free to share your suggestions.

Thanks !!