In this third and final post about Power Automate and its connector for Microsoft Dynamics 365 Finance and Operations apps, we are going to talk about the different write operations that exist in it. These operations are the following:
Before starting with them, we must bear in mind that these operations will be available only for those entities that have the Is Read Only property with value No, that is, entities that allow data to be written.
In fact, Power automate itself warns us, as we can see in the following screenshot:
Create record
We will use the Create record action, obviously, when we need to create new data within MSDyn365FO.
The first thing we need to indicate is the Instance on which we are going to work, and the entity on which we want to create new data. Once these two parameters have been selected, we will see how the necessary fields appear to be able to create the new record.
Continuing with the Customer group entity, we will indicate the minimum data necessary to be able to create the record, which are the customer group code and the company code. If we click on the link Show advanced options, the rest of the fields that are available within the entity will appear to complete the information. Once the flow is executed, we can see how the record has been created in the system.
Now, if we consult the IIS log of our instance, we can verify that Power Automate is making a POST http call over Dynamics 365, sending the data that we have completed in the flow in the body of the call.
1 |
2020-12-20 18:22:31 POST /data/CustomerGroups ja.tomas@axazure.com - 201 |
1 2 3 4 5 6 7 8 9 10 11 12 |
{ "dataAreaId": "usmf", "CustomerGroupId": "JAT", "ClearingPeriodPaymentTermName": "", "CustomerAccountNumberSequence": "", "DefaultDimensionDisplayValue": "", "Description": "", "IsSalesTaxIncludedInPrice": "No", "WriteOffReason": "", "PaymentTermId": "", "TaxGroupId": "" } |
Update a record
We can use the following action when we need to update a record within Dynamics 365 Finance and Operations apps.
If you look closely, this operation is very similar to the action we saw in the previous article with which we could Get a record. We must indicate the instance and entity on which we want to act, and we also have to enter the object Id that uniquely identifies the record we want to update. As we saw earlier, this is generally the company code, followed by the primary key of the entity.
Once these values are indicated, it also forces us to put the mandatory values, such as the Customer group (although it does not use that value to update), and if we are going to see the advanced options, the rest of the fields available in the entity will appear for you to update its value.
Once the action is executed, we can see how 2 operations appear in the IIS log:
1 2 |
2020-12-20 18:59:40 PATCH /data/CustomerGroups(dataAreaId='USMF',CustomerGroupId='10') ja.tomas@axazure.com - 204 2020-12-20 18:59:40 GET /data/CustomerGroups(dataAreaId='USMF',CustomerGroupId='10') ja.tomas@axazure.com - 200 |
These operations are, first a PATCH call, which it executes to update the record in question, followed by a GET operation that Power Automate performs to obtain the updated data of the record with which we are working, and thus be able to use them as Output of the action, and have these values in the next steps of our workflow.
Caution!: In the second GET operation, the system does not use the Object Id to obtain the data, but rather, it is using the CustomerGroupId, so if in the CustomerGroupId we put a different value to the Object Id, although we will correctly update the record that we indicate in it, the data that we will obtain in the output will be different. As you can see in the following image, the system would launch a PATCH against a record, and a GET on a different one. A little “crazy”, right?
In this action, just as it happened with the Get a record action, we must take special care with the order of the parameters within the Object Id, and we also have the limitation of the company assigned within MSDyn365FO, so if we try to update a record from a different company, we will find a 404 error as it will not find the resource to update.
Delete record
And we arrive to the last of Power Automate’s actions on MSDyn365FO: Delete record. As its name indicates, what we achieve with this action is to delete a record within the entity indicated in the input parameters.
To identify the record that we want to delete, we will follow the same mechanism as the one indicated in the actions of Get record and Update a record, that is, we will indicate the Dynamics 365 instance, the entity on which we want to act, and in the Object Id , we put the company followed by the primary key of the entity.
As we have seen a while ago, we must be strict with the arrangement of the elements that make up the Object Id, and again, we have the limitation created by not being able to use the cross-company parameter within this type of actions, so if we try to delete a record from a company other than the one assigned to us, we will find an error that is already known to everyone.
Finally, we are going to check the IIS log again to review the HTTP operation that Power Automate performs on our Dyn365 F&O instance.
1 |
2020-12-20 18:41:08 DELETE /data/CustomerGroups(dataAreaId='USMF',CustomerGroupId='JAT') ja.tomas@axazure.com - 204 |
This operation is a DELETE on the entity that we have indicated, taking the values that we have put in the Object Id to identify the record in question.
And here ends this series of posts about the Power Automate connector for Microsoft Dynamics 365 Finance and Operations. As you have seen, we can perform practically any type of operation with it, although it is true that we have a series of limitations and problems that can make it difficult for us to design a solution using this tool.
I hope you liked them and you found them useful. As always, I am open to any type of comment, doubt or criticism, and it only remains to wish you happy holidays and a happy new year
See you in 2021!! ✨
Thanks. Can you write(and read) binary data? For example, attach image or file to a record?
Hi Denis, thanks for commenting :).
Yes, indeed I have a power app to attach images to released products through Power automate. I expect to create a post with the details soon.