Fetching Report Data in the Flow Designer

Last 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.

01.-report_email.png

We will begin by navigating to a Designer Folder and clicking the Create Report button.

createReport

 

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.

nameReport

 

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.

dragVehicleFolder

 

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.

addColumns

 

This completes our report, so we will save it and close the Report Designer.

saveReport

 

Next, we will create the flow which will send our report email. Back in our Designer Folder, we will click the Create Flow button.

createFlow

 

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.

nameFlow

 

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.

 

 flowStarts

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.

addStringData

 

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.

dragRunReport

 

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.

dragForEachStep

 

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.

pickTypeForEach

 

Next, we will open the Mapping Editor and map All Cars Report to Collection.

mappingForEach

 

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.

dragCustopMerge

 

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.

makeTemplate

 

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.

mappingToCustMerge

 

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.

dragSecondCustMerge

 

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.

templateForSecondMerge

 

In the Mapping Editor, we will map Flow Data.StartTime to FlowStartTime and ReportTableRows to ReportTableRows. We will also rename our output to “EmailBody”.

mappingForCustMergeSecond

 

Finally, we will send our Email. We will find the Send Email component in the Toolbox tab, under the category Communication.

dragSendEmail

 

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.

mappingToSendEmail

 

Once our remaining outcomes have been connected, our flow will be complete. We will save it and close the Flow Designer.

saveFlow

 

Back in our Designer Folder, we will select Email Cars Report and select the Run Flow action.

runFlow

 

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.

25.-report_email.png

Additional Resources