First you need to create an App Registration in Azure Portal, you can follow steps provided by Benitez Here.
After that steps has been completed we will create the custom Connector and create the actions steps.
1. Creating an action that will generate a PDF
To create a new action
- Click on +New action.
- Enter a name.
- Enter a value for the Operation ID, I use the same value as the name but all in lowercase.
- Click on +Import from sample to create the API request.
- Select the method of the API request. In my use case it is POST.
- Provide the URL of the API request. In my use case it is
- https://(ORGNAME).crm.dynamics.com/api/data/v9.2/ExportPdfDocument
- Provide the JSON Payload.
{
"EntityTypeCode": 1090,
"SelectedTemplate": {
"@odata.type": "Microsoft.Dynamics.CRM.documenttemplate",
"documenttemplateid": "153dc496-d79d-e711-8109-e0071b65ce81"
},
"SelectedRecords": "[\"{E3A79DA1-9B91-E811-8133-E0071B65CE81}\"]"
}
- Click Import.
- Click Update Connector.
You can test it by
Filling it out like
It all looks the same, the only thing to look at is the SelectedRecords. You will need to pass it with the extra chars.
[“{DynamicsGUID}”]
Creating an action that will create the PDF as an activitymimeattachment record
To create a new action
- Click on +New action.
- Enter a name.
- Enter a value for the Operation ID, I use the same value as the name but all in lowercase.
- Click on +Import from sample to create the API request.
- Select the method of the API request. In my use case it is POST.
- Provide the URL of the API request. In my use case it is
- https://(ORGNAME).crm.dynamics.com/api/data/v9.2/activitymimeattachments
- Provide the JSON Payload.
{
"objectid_activitypointer@odata.bind": "/activitypointers(0fb39275-4081-ec11-8d21-0022481d3cff)",
"objecttypecode": "email",
"body": "SGVsbG8gV29ybGQhIFRoaXMgaXMgYSBkZW1v",
"filename": "HelloWorld.txt",
"subject": "Hello World"
}
- Click Import.
- Click Update Connector.
You can test it by
Filling it out like
The Body is Base64 encoded.
Now you can use this in Power Automate Flows.
Huge shout out to Benitez Here for showing this