Initializing help system before first use

Formatting the Optimal Result with JavaScript

The Xpress Insight JavaScript API enables you to invoke a wide range of library functions from within VDL.

You can also create your own JavaScript functions within VDL via <script> blocks, but here, the Return scalar is formatted via a call to an existing function—insight.Formatter.formatNumber—which takes two arguments:

  • the value to be formatted (here, this is the value of scenario.entities.Return.value), and
  • a Java-style formatting string.
  1. If it is not already active in Workbench, open the Portfolio.vdl file.
  2. On the artboard, select the Text field "=scenario.entities.return.value".
  3. In the Attributes pane, edit the Text attribute. Delete the existing entry and replace it with the following JavaScript instruction.
     =insight.Formatter.formatNumber(scenario.entities.Return.value, '00.##')
  4. Republish the app to see the changes.