Fetching Report Data in the Flow DesignerLast Updated: 08/12/2016 Introduced in Verision: 2.0 |
Report components make report data available for use in flows. Report components can be found in the Toolbox tab, under the category Integration > Reporting.
Example
In our example flow, we will email a report of all the Cars (a custom folder extension type) in our system to a user. Report data will be displayed in an HTML table.
We will begin by navigating to a Designer Folder and clicking the Create Report button.
In the resulting New Report pop-up, we will name our report “All Cars Report” and click OK to open it in the Report Designer.
The source of our report data will be the custom folder extension type Car. We will find the Vehicle [Folder] source in the Toolbox tab, under the category Data Sources > Common > Extension Data.
Next, we will define the columns of our report: Make, Model, Color and Year. We will drag them to the Results tab from the Toolbox tab, under the category Columns.
This completes our report, so we will save it and close the Report Designer.
Next, we will create the flow which will send our report email. Back in our Designer Folder, we will click the Create Flow button.
In the resulting New Flow pop-up, we will name our flow “Email Cars Report” and click OK to open it in the Flow Designer.
We will begin by creating the String which will contain our table rows. We will find the Create or Copy Data component in the Flow Designer start-up window tab, under the category All Steps [Catalog] > Data.
In the Data Definitions section of the Properties tab, we will click the Add button. In the resulting Edit object pop-up, we will name our String “ReportTableRows” and click OK.
Next, we will retrieve the data generated by our report. We will find the All Cars Report component in the Toolbox tab, under the category Integration > Reporting.
Next, we will iterate through the rows of our report. We will find the ForEach Step component in the Toolbox tab, under the category Flow Management.
To iterate through our report rows, we will have to define the appropriate data type for our ForEach Step component. In the Collection section of the Properties tab, we will open the Type selector and select a data type of “RunAllCarsReport”. This data type correlates directly to our report and contains rows of data correlating to the columns of our report.
Next, we will open the Mapping Editor and map All Cars Report to Collection.
As we iterate through our report rows, we would like to compose HTML table rows that we can later embed in an email. For this, we will use the Custom Merge [NVelocity] component. It can be found in the Toolbox tab, under the category Data > Text.
In the Merge Setup section of the Properties tab, we will define the template into which our table data should be put. Because our rows are aggregated, we will begin with the previous rows – ReportRowTables, followed by a line break. In subsequent lines, we will define a table row containing four cells: Make, Model, Color and Year. As we define variables in our template, the Custom Merge [NVelocity] component generates the inputs for populating these variables.
In the Mapping Editor, we will map ReportTableRows to ReportTableRows and rename the output to “ReportTableRows” as well. Next, we will map the make, model, year and color properties of each Item to their respective inputs.
When our flow has finished creating table rows for each report row, we would like to embed those rows within the template of the email. For this, we will use another Custom Merge [NVelocity] component.
In the Merge Setup section of the Properties tab, we will define some introductory text for our report, including the date and time when the report was generated, and the surrounding HTML markup for creating a table, including column headers.
In the Mapping Editor, we will map Flow Data.StartTime to FlowStartTime and ReportTableRows to ReportTableRows. We will also rename our output to “EmailBody”.
Finally, we will send our Email. We will find the Send Email component in the Toolbox tab, under the category Communication.
In the Mapping Editor, we will set From to “admin@example.com”, To to “mary.anne.watson.73@gmail.com”, and Subject to “Cars Report”. We will set Send as Html to True and map EmailBody to Body.
Once our remaining outcomes have been connected, our flow will be complete. We will save it and close the Flow Designer.
Back in our Designer Folder, we will select Email Cars Report and select the Run Flow action.
Upon completion, our report email will be sent to mary.anne.watson.73@gmail.com. If we go to this account’s inbox, we will see the email we constructed.