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()

Constructor functions​

FunctionDescription
Composition()Creates a new composition configuration
DynamicReport()Creates a new dynamic report configuration
FixedReport()Creates a new Fixed report configuration
InsightReport()Creates a new insight report configuration
Report()Creates a new report configuration
WidgetReport()Creates a new widget report configuration

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
cacheOptionsSet the SMART caching options for this reportSmartReportCachingOptions
cronThe cron expression to trigger this report, you must also set the enabled flag to trueString
currencyThe optional currency of this report, can be used in the function using #REPORT.currencyString
defaultRangeThe optional default range for this reportString
enabledThe enabled flag is used in conjunction with the cron expression to turn on/off the schedule triggered running of this reportBoolean
endThe end date used to generate this reportDate
hideExcelHides this report from the Excel Add-inBoolean
hideListHides this report from the Reports listBoolean
mergeKeysFixed reports only: the field names used to match array elements when merging updates, the first one present in an element is usedList
mergeUpdatesFixed reports only: when true, updating the report for an ondate merges the supplied data into the existing report instead of creating a new versionBoolean
ondateThe report publish dateDate
reportThe id of the reportString
reportTypeThe type of this report, one of Default, Fixed, Dynamic, Insight or WidgetString
startThe start date used to generate this reportDate
subCategoryThe user defined sub category for this reportString
templateThe mustache template used when outputting this reportString
timezoneThe optional timezone of this report, can be used in the function using #REPORT.timezoneString
unitsThe optional units of this report, can be used in the function using #REPORT.unitsString

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
withAggregationOnDateGenerator(service, source, aggregation)Use an aggregation pipeline to generate the dates for this reportODGAggregation
withCalendarOnDateGenerator(calendar, start)Use a calendar to generate the dates for this reportODGCalendar
withCurveOnDateGenerator(id)Use the dates of a curve to generate the dates for this reportODGCurve
withDistinctOnDateGenerator(service, source, field)Use a distinct find query to generate the dates for this reportODGDistinct
withDistinctOnDateGenerator(service, source, field, filter)Use a distinct find query to generate the dates for this reportODGDistinct
withFilterOnDateGenerator(service, source, filter, projection)Use a filter to generate the dates for this reportODGFilter
withMatrixOnDateGenerator(id)Use the dates of a matrix to generate the dates for this reportODGMatrix

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 specific saved report​

rep = ${report:"REPORT.SKU:2026-09-30"}
print rep.data

Get the latest saved report​

rep = ${report:"REPORT.SKU:L"}
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:TEST}
print ${report:"TEST:L"}