Creating a JavaScript Include File

You have the option of placing any functions or variables that you want to access from the expressions in your view model in a JavaScript include (.jsi) file. JavaScript include files facilitate code reuse.

Perform this task with your view model open.

To create a .jsi file for your view model:

  1. Right-click the background in the view model editor and choose Open JSI File from the context menu. WorkSpace creates the file if it doesn’t already exist and opens it in a text editor.
  2. Edit the JSI file to include any functions, variables, or other JavaScript code you like.
  3. Right-click in the editor and select Save to save the file.

Sample JSI File for Converting Date Objects

Suppose your model requires converting Date objects into integers of the format “yyyymmdd.” Create a function like the following in your JSI file. You can then call it from multiple places within your view model (such as Projection column definitions).

// Convert a Date object to the form "YYYYMMDD" as an int
function dateToInt(dateObject) {
	    return dateObject.getFullYear() * 10000 +
        (dateObject.getMonth() + 1) * 100 +
        dateObject.getDate();
}
Related concepts
Custom Properties: Custom Code for Custom Operators
Related tasks
Setting Generator Properties

Send your feedback on this help topic to Sybase Technical Publications: pubs@sybase.com

Your comments will be sent to the technical publications staff at Sybase, Inc. For product-related issues or technical support, contact Sybase Technical Support at 1-800-8SYBASE.