top of page

Implementation - Cases Sync in Dynamics 365 Environments

Writer's picture: Girijesh DixitGirijesh Dixit

Explanation of how to sync two dynamics 365 environments cases via the Power Automate.


Step1- Create a App User

Create a App user and assign Administrator role on source environment.


Step 2- Create a Child Power Automate - Source Env.

  • Add a Add Dataverse connector “When a row is added, modified or deleted” and set the trigger point on Case entity

  • Add and save a HTTP request connector in Master Power Automate, The HTTP request URL will used in Child Automate to invoke

  • Add HTTP action connectors in Child Power Automate to invoke Master Power Automate and pass the created incidentId {GUID} as a parameter

HTTP request.{

"inputs": {

"method": "POST",

"uri": "https://prod-02.centralindia.logic.azure.com:443/workflows/62f97cd457fd4903a7cb384d8e6a5a34/triggers/manual/paths/invoke?api-version=2016-06-01&sp=%2Ftriggers%2Fmanual%2Frun&sv=1.0&sig=wklmTQr7De3yjPaKxcfMEj1sySa3BikrAT_8nLMDWLQ",

"headers": {

"CaseId": "@triggerOutputs()?['body/incidentid']"

}

}

}

Child Power Automate


Step 3- Create a Master Power Automate - Target Env.

  • Add a HTTP request connector "When a HTTP request in received".

  • Receive the passed incidentId{GUID} from Child Power Automate from header

{

"inputs": "@triggerOutputs()['headers']?['CaseId']"

}


Method POST

URI https://login.microsoftonline.com/***************/oauth2/token

Headers Application/x-www-form-urlencoded

Body grant_type=client_credentials&

client_id=*********************************

client_secret*******************************

  • A data operation “compose” to get access_token after HTTP action

{ "inputs": "@outputs('HTTP').body.access_token" }

  • Add another HTTP Action to make a query and retrieved Case details from the source environment

Method GET

URI https://orgc****d8cf.crm8.dynamics.com/api/data/v9.1/incidents

Headers Content-Type – application/json

Authorization "@{outputs('Compose')}"

Filter "incidentid eq '@{outputs('CaseId')}'"

  • Initialize the output of HTTP2 Action and store it in a variable

{

"inputs": {

"variables": [

{

"name": "HttpBody",

"type": "object",

"value": "@body('HTTP_2')"

}

]

}

}

  • Extract the case details from the above JSON object and store them in a variable

{

"inputs": {

"variables": [

{

"name": "CaseDetails",

"type": "array",

"value": "@variables('HttpBody').value"

}

]

}

}

  • Parse the Case attributes values from case details.

  • Check if the case id already exists in the target environment

{

"inputs": {

"host": {

"connectionName": "shared_commondataserviceforapps",

"operationId": "ListRecords",

"apiId": "/providers/Microsoft.PowerApps/apis/shared_commondataserviceforapps"

},

"parameters": {

"entityName": "incidents",

"$filter": "incidentid eq '@{outputs('CaseId')}'"

},

"authentication": "@parameters('$authentication')"

}

}

  • Based on the condition the Add/update trigger will execute.


Master Power Automate

Demo




Kindly write me on Girijeshdixit@hotmail.com for any query regarding this demo.


Happy learning..

Recent Posts

See All

Comments


Stay up to date with my latest blog posts

Thanks for submitting!

For general inquiries, please get in touch

Thanks for submitting!

© 2020 by Girijesh Dixit

bottom of page