Skip to main content

Report

A report is a configuration containing an expression that can be run to produce a user definable report.

Introduction

A report is a flexible way of running some code to produce an output that can be shown in the Web Portal and the Excel Add-in or sent to a downstream system.

An example of a report is an aggregation of some data grouped by a specific field.

Construction

To construct a new report configuration, you use the report function as shown in the syntax below:

report = Report()

Properties

A report has the following properties:

NameDescriptionType
categoryThe category of this report, used for filteringString
nameThe name of the reportString
descriptionA description of the report
scriptThe name of the script used for this reportString
expressionThe expression used to run this reportString
tagsA list of tags used to filter for this reportList of Strings

Examples of report properties:

rep = Report()
rep.name = "SKU Report"
rep.script = "testReportScript"
rep.expression = "SKUReport()"
rep.id = "REPORT.SKU"

save rep

Methods

A report has the following methods:

NameDescriptionReturn Type
build()Run the expression to build the reportreport
build(date)Run the expression to build the report specifying a date to start fromreport
build(date, date)Run the expression to build the report specifying a date rangereport

The result of running any of the build commands is a filled out report.

Filled out report

Properties

A filled out report has the following properties additional to the report configuration properties:

NameDescriptionType
dataThe variable created from running the reportAny
errorMessageIf the report fails to execute, this will be filled in with the error messageString
scriptVersionThe version of the script used to run this expressionNumber

Examples

Create a report

rep = Report()
rep.name = "SKU Report"
rep.script = "testReportScript"
rep.expression = "SKUReport()"
rep.id = "REPORT.SKU"

save rep

Get a report configuration and run it

rep = ${reportconfig:"REPORT.SKU"}
test = rep.build("2023-02-01", "2023-02-28")
print test.data

Run the report

rep = ${report:"REPORT.SKU"}
print rep.data

Run the report with a range

rep = ${report:"REPORT.SKU", "_range=from(2023-02-01)"}
print rep.data

Run and save a report

save ${report:"REPORT.SKU"}

Get a saved report

rep = ${report:"REPORT.SKU/~LATEST"}
print rep.data

Run and save a report with a range

save ${report:"TEST", "_range=from(2023-02-01)"}

Save a var as a report

TEST = ["Hello","World"]
save ${report:REPORT.SKU}
print ${report:"REPORT.SKU/~LATEST"}