In order to get Dundas BI JavaScript services using the JavaScript API there are two approaches:
When editing dashboards or other views in Dundas BI, you can add script actions in the Properties window on a control (adapter) or to the view itself. For more information on the script editor, see Using the script editor. Within the script editor, to get a Dundas BI service you would use the this keyword which represents the control or view adapter you added the script to and contains a getService method.
The example below shows how you could get the file system service (or any other service) from a script action:
1 2 | // Get file system service. var fileSystemService = this .getService( "FileSystemService" ); |
The main reason to use this rather than dundas.context in script actions is into ensure the script works correctly when embedded inside another dashboard or view. For more information, see Using a view container.
If the script is not part of a script action, the this will not have this same context. In this case, to get services you should use dundas.context. This property value is of type dundas.bootstrap and contains a getService method.
The example below shows how you could get the file system service (or any other service) from outside of a script action:
1 2 | // Get file system service. var fileSystemService = dundas.context.getService( "FileSystemService" ); |
Service names can be determined by viewing the Inheritance Hierarchy on the dundas.Service class. Each service derived from dundas.Service can be retrieved by using the last part of the name and passing that to the getService method. For example, the full name dundas.account.AccountService can be requested as just AccountService.
1 2 3 4 5 6 7 | // Get account service from this. var accountServiceFromThis = this .getService( "AccountService" ); // Or // Get account service from dundas.context. var accountServiceFromDundasContext = dundas.context.getService( "AccountService" ); |