Scripting in FDM is used to perform a multitude of tasks. The most common uses are to create reports and widget outputs, but with some tweaking of settings they can be used to expose web services, perform automated jobs for analysis and calculations, and provide data export channels.

This article will explain how to perform common tasks with the FDM scripting tools. It is targeted at users with a basic knowledge of development using JavaScript and/or Java.

More in-depth documentation can be found at

Scripting Core Variables

Before executing a script the FDM service will prepare some variables that help the developer access the underlying APIs:

valueDate The date to run this script on. This allows for future or past execution dates to be supported. e.g. for reporting.
FDMContainer Advanced API access is made via this object. It gives access to low-level management objects via InsightContainer
FDM A ScriptingHelper object. This object is used to pass information back to the calling process, e.g. to return HTML.
runmode The mode the script is running in. HEADERLESS,DEVELOPER
currentObject The Insight object representation of the object running the script. Can be NULL.
scriptStartDate Where applicable the start date to be applied to the script. Can be NULL.
scriptEndDate Where applicable the end date to be applied to the script. Can be NULL.

Returning HTML Content

To return HTML content (or any text based content, such as CSV if returning data) use the FDM.body variable. For example:

Copy to Clipboard

Returning Spreadsheet Content

To return cells into the FDM client spreadsheet view use the FDM.setSpreadsheetCell ( CELLID, ROWID, STRING ) function. For example:

Copy to Clipboard

Working With HTML & Other Content

Rather than having to encode HTML or other text content into scripts it is possible to use the Content Manager to load predefined content. This can be snippets of content (for example, row structures for an HTML table) or can be an entire document structure. This is designed to be used by either adding the content to the main body of the script output, or by performing a search and replace on key-holder variables within another body of text. For example, creating an HTML structure that defines an entire report, then replacing %%CUSTOMERLOGO%% with a <img src=”example.png”>, created within the script.

Copy to Clipboard

Working With Objects

Copy to Clipboard

Working With Data

Data in FDM is stored in ‘data stores’. Individual records are uniquely identified using a device or data reference. e.g. a serial number of a device.

Data is split into two types: header data, which has one record per unique id, and time-series data which has a record per timestamp for each device id.

Each object can be directly linked to a single data store and data reference, however it is possible to link data together by accessing stores directly from within scripts. This can be used to perform lookups (e.g. a device has a code stored in an attribute or header field. This can then be looked up from a central table to retrieve the description for this code in one or more languages).

Copy to Clipboard
Copy to Clipboard