Power Automate: Create an Excel file during runtime and send it as email attachment through MS Flows
I was working on a requirement where Dataverse entity record needs to be export in excel and send as an email attachment.
In this scenario, each record must have a separate excel file, and as we know there is no way to create an excel file dynamically through flow.
To achieve the above task, I have followed below steps:
Step 1:
I created an excel template in one drive and this template has one table and two columns i.e. Name and City:
We can increase/decrease columns as per requirement.
In this example, my template name is "Sample sheet.xlsx"
Step 2:
Create a Microsoft flow that triggers on the creation of "Contact" in Dataverse:
Then add a new step to get the file template from one drive that was created in Step 1:
Next, Add a new step to copy the template with a new name at a new location on onedrive:
I have created a new folder with the name "Copies" in onedrive before creating the above step.
The next step is to compose rows, In step 1, I have created two columns in the template and here I am assigning value in those two columns:
In file column, I have written below expression:
split(outputs('Copy_template_in_new_location')?['body/Id'],'.')[1]
In this expression, I set id of step "Copy template in new location".
In Row, Set output of step "Compose rows".
The next step is for delay 5 seconds:
Next, Get updated file content:
Finally, send email and set file content as an attachment:
Save the flow and test it.
The final layout of the flow will look like this:
The best Article that I have never seen before with useful content and very informative.Thanks for sharing info. Dynamics 365 Marketing Functional Consultant Associate
ReplyDelete