CRM Crate

Model-Driven App | Upload, Download & Delete a File using Power Automate

We will learn to upload, download and delete a file in Dynamics 365 CRM. Before we start, make sure to subscribe to CRM Crate so that you can stay up to date in the field of Dynamics 365 CRM.

Model-Driven App | Upload, Download & Delete a File in Dynamics 365 CRM

Understanding the File type attribute in Model-Driven App

A file attribute / column is used for storing file data up to a specified maximum size. A custom or customizable table can have zero or more file columns plus a notes collection with zero to one attachment in each note. The SchemaName of the file column is “EntityFile”.

We can create a File data-type field within a Model-Driven App as shown below.

Download, Upload & Delete the data in a File using Power Automate

We will learn to automatically download or retrieve data from a file, upload or push data into a file and delete or remove a data from a file data-type field using Power Automate flow as given below.

Download a file data using Power Automate –

In our scenario, we will download the data from a file type attribute called “File A” as shown below.

We will use the Power Automate’s connector called “Download a File or an Image” for performing the operation.

Below are the properties and parameters required by the “Download a file or an image” connector.

Table NameSelect the table / entity in which the File type attribute is present
Row IDPass the row / record’s GUID for patching the request
Column NameSelect the File type attribute as per your requirement

Upload a file data using Power Automate –

In our scenario, we will upload the data into a file type attribute called “File B” which was previously downloaded from attribute called “File A”.

We will use the Power Automate’s connector called “Upload a File or an Image” for performing the operation.

Below are the properties and parameters required by the “Upload a file or an image” connector.

Table NameSelect the table / entity in which the File type attribute is present
Row IDPass the row / record’s GUID for patching the request
Column NameSelect the File type attribute as per your requirement
ContentPass the content data downloaded from the previously used “Download a file or image” connector
Content NamePass the name of the file from which the data is getting copied. In our example, we will be retrieve the file name present in the attribute “File A”. Thus, it will be “outputs(‘Get_Row’)?[‘body/cc_filea_name’]

Delete a file data using Power Automate –

In our scenario, we will delete the data from a file type attribute called “File B”.

There is no out of the box connector available for deleting the data from File attributes. Therefore, we will use the out of the box action called “DeleteFile” for sending a file deletion request. The Power Automate’s “Perform an unbound action” connector will be used for calling the DeleteFile action.

Click on the given link to learn more about DeleteFile action- https://docs.microsoft.com/en-us/power-apps/developer/data-platform/webapi/reference/deletefile?view=dataverse-latest

Below are the properties and parameters required by the “Perform an unbound action” connector.

Action NameSelect the out of the box action called “DeleteFile”
FileIdPass the ID of the file attribute captured during retrieving the row (Get Row By ID connector)

Validate the implementation in Dynamics 365 CRM

Once the above shown Power Automate flow is designed, navigate to the Dynamics 365 CRM and validate the implementation as shown below.

Note: – We have developed an additional JavaScript logic for triggering the Power Automate flow during the “OnChange” event of form’s field.

Thus, we learned to upload, download and delete a file in Dynamics 365 CRM.

5 1 vote
Article Rating
Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments
error: CRM Crate Security Engine - Disabled Right Click & Selection!

Congratulations!

Well Done,
Welcome to CRM Crate

Stay tuned with us and get all latest updates and learning in Microsoft CRM and related techonologes.