InetSoft Dashboard Software - Using Scripting in a Dashboard Report

Scripting in a dashboard report give users full control of InetSoft's dashboard software for the highest level of customization available. View the example below to learn more about the Style Intelligence solution.

Because scripts are executed when the Viewsheet is generated on the server, a script error can cause Viewsheet generation to fail.

To prevent this from happening, you should wrap error-prone code inside a “try-catch” block, which allows you to trap errors before they affect Viewsheet execution.

When you attempt to debug a Viewsheet script, it is often helpful to view the current values of variables and objects. To do this, use the alert() function, which opens a dialog box to display a specified string.
You can also use the alert dialog box to display critical information to a user (e.g., that the user's selections have resulted in an empty dataset being returned).

#1 Ranking: Read how InetSoft was rated #1 for user adoption in G2's user survey-based index Read More

This section discusses several basic date functions.

The ateDiff()' function is used to find the difference between two dates in days/months/years.
dateDiff('d', fromDate, toDate); // days
dateDiff('m', fromDate, toDate); // months
dateDiff('yyyy', fromDate, toDate); // years

For example, if we have a table bound to a query which contains the date field 'Birth Date', we can create a formula field (in the data binding dialog) that calculates the age of this Birth Date in years by subtracting the birthday from the current date. The script of this formula field is shown below.
dateDiff('yyyy', field['Birth Date'], CALC.today())
The 'dateAdd()' function is used to find a date which is n number of days/months/years before/after another date.
// 1 day before today
dateAdd('d', -1, CALC.today());

// 5 months after today
dateAdd('m', 5, CALC.today());

// 3 years before Order Date
dateAdd('yyyy', -3, field['Order Date']);
For example, wish to run a query in script; this query takes in two date parameters namely 'StartDate' and 'EndDate'. We want the query to always fetch data which is 15 days before the today and 15 days after today.
var sd = dateAdd('d', -15, CALC.today());
var ed = dateAdd('d', 15, CALC.today());
var q = runQuery('Order Bookings',
        [['StartDate', sd],['EndDate', ed]]);

Read what InetSoft customers and partners have said about their selection of Style Scope for their solution for dashboard reporting.

Previous: Dashboard Report Scripting