Today, I noted how to use Power Auotomate download SSRS Report, and send it via email.
This is a question from my teammate and I feel it's very exciting because I have faced this requirement from many clients before. Last time, my dev team did the C# code to generate the report and attached this report to the email for sending. Now, after researching & learning, I try to use the Power Automate with action HTTP Request to do that.
My scenario
The customer is using the Work Order process:
Engineers use a Work Order to log inspection and work results at customer sites.
After work completion, the customer signs the Work Order mobile form.
The engineer marks the Work Order as complete, triggering an immediate Work Order Summary report (of the current Work Order) to be sent to the customer.
My proposal
I'm using the Power Automate to configure this scenario:
Components
Flow summary
Details of configuration.
For instance, I already created the report called WOSummary report,and runs on the Work Order main form.
When a Work Order is completed, the Power Automate will be triggered -> then download the WOSummary report and send it to the customer.
The configuration details are as below:
Trigger: Work Order Modified on field "Status Reason"
Filter: Status Reason = Completed <--> statuscode eq 2
This step uses the action Initialize Variable to set report pre-filtering when calling HTTP request - Report Viewer at Step(4)
We using the XML format
How to find the report filter code?
My sample report "WOSummary" was enabled pre-filtering so we need this step to set the Pre-filtering for a report when running the HTTP Request (apply for current Work Order triggered).
After converting the XML format, then copy it to Power Automate and replace the attribute with Dynamic Values at Step(1).
List rows: get a List of report records on the table "Reports"
Filter rows: Report Name = "WOSummary" <--> name eq "WOSummary"
This step is to call an HTTP request to view the WOSummary report of the current Work Order. And scope is run on Apply to each (value): The report in Step (2)
Method: POST
Url of the request: /CRMReports/rsviewer/reportviewer.aspx
Body of the request:
id = [[Report]]&CRM_Filter=encodeUriComponent([Report Filter XML])with: + [[Report]]: this is Report GUID in Step (3)
+ Expression: encodeUriComponent([[Report Fitler XML]])
with [Report Filter XML] at Step(2)
Note: We must authenticate first
Base resource URL: this is your environment URL (Power Platform/ CE environment)
Microsoft Entra ID Resource URL (Application ID URI): this is your environment URL (Power Platform/ CE environment)
Using code block:
Using expression with Dynamics Value: Body of step WOSummary Viewer step(4)