Custom JavaScript function (JS-function) is available for connection:
In the Dashboards tool to select the JS-Function Call item using the Button control.
In the Reports tool and in the Interactive Data Entry Forms extension:
To set up hyperlink link action in the regular report and data entry form specified in report/data entry form cell.
To set up action, prehandler, posthandler of the custom button added on the toolbar in regular reports and data entry forms.
In the web application in the Designer of Business Applications extension to subscribe to events:
On rendering page type: login, navigator or object.
On object opening.
On opening folder in the object navigator.
To connect custom JS-function:
Create a JS-file containing the custom JS-function in the folder with installed web application/designer of business applications.
The path to the folder with installed web application if plugin description is added in the config.json file:
In Linux OS: /opt/foresight/fp10.x-webserver/r.
In Windows OS: C:\Program Files (x86)\Foresight\Analytics Platform 10.x Web Application\r.
The path to the folder with installed designer of business applications:
If the designer of business applications back end is installed automatically on Apache2 web server or manually on IIS:
In Linux OS: /opt/ERROR: Variable (Company_distr) is undefined./fpERROR: Variable (Version_for_setup) is undefined.-dba;
In Windows OS: C:\Program Files (x86)\ERROR: Variable (Company) is undefined.\DBA_ERROR: Variable (Version_for_setup) is undefined.. The DBA_ERROR: Variable (Version_for_setup) is undefined. folder is created manually and may differ.
If the designer of business applications back end is installed manually on Apache2 web server, Java or automatically on IIS:
In Linux OS: /opt/foresight/dba/10.x.
In Windows OS: C:\Program Files (x86)\Foresight\Designer of Business Application 10.x Web Server.
TIP. To facilitate the use of plugins, create the Plugins folder, which will store plugins.
In Linux OS grant permissions for the custom folder with plugins/created JS file in Debian-based distributions for the www-data user. When working in other Linux OS distributions replace www-data with apache for RedHat-based distributions or with apache2 for ALT Linux.
For example, the Func.js file:
function myFunc(){
alert("Example of calling custom JS-function from file");
}
Examples of functions are given in the description of signatures.
Add a link to the created JS-file in the externalJs field in the config.json configuration file for the web application or in the config.json/DBA.config.json configuration file for the designer of business applications. To do this specify the path to the JS-file relative to the main file index.html of web application/designer of business applications:
"externalJs": [{"src": "./Plugins/Func.js"}]
Restart the back end of web application/designer of business applications.
After executing the operations the custom JS-function is connected to the corresponding object when function name is specified in JS-function call settings.
Connect custom JS-function in the web application with the PP.xml configuration file
Custom JS-function signature for dashboard
Custom JS-function signature for regular reports and data entry forms if a custom button is set up
Custom JS-function signature of regular report/data entry form if hyperlink is set up
Custom JS-function signature for web application and designer of business applications
Features of JS-function argument use in the web application with the PP.xml configuration file
JS-function signature of hyperlink/custom button uses the args parameter:
The moduleId field returns unique identifier of the opened object instance, from which JS-function is called. This identifier is used by methods of the Platform.Managers object.
Platform.Managers - object that allows access to opened repository objects, from which JS-functions are called. In the current implementation the following objects are implemented for this object:
Metabase. It contains methods for getting information about opened repository:
connectionId(). Moniker of opened repository.
userName(). Repository name
Prx. It allows access to regular report. The object contains the fields:
selectors. It contains selectors for getting information about opened object:
id(). Object identifier.
name(). Object name.
key(). Object key.
openId(). Moniker of opened object instance.
actions. It contains methods:
refresh(). Refresh opened object
refreshTabSheet(). Refresh table
loadSourcesMetadata(). Refresh information about data sources
setIsDirty(). Get whether there are unsaved changes in report
DataEntryForm. It allows access to data entry form. The object contains the fields:
selectors. It contains selectors for getting information about opened object:
id(). Object identifier.
name(). Object name.
key(). Object key.
openId(). Moniker of opened object instance.
actions. It contains methods:
refresh(). Refresh opened object.
The following objects of the Platform namespace are also available when working with regular reports/data entry forms in JS-functions:
Platform.Bi - object containing methods for interaction with BI server by means of JSON queries. The list of methods and their signatures:
execMethod(apiComponent, module, methodName, args, objectToSave, batched) - to execute queries using the ForeExec operation. Where:
apiComponent: string. Identifier of the container. If the container is not used, specify null.
module: number | string. Key or identifier of the unit/assembly containing implementation of the executed method. For example:
If the unit/assembly is located in the container:
'!module'
If the unit/assembly is located outside the container:
'Platform.Managers.MetaBase.connectionId()+'!module'
methodName: string. Executed method name.
args []. Method arguments. Optional parameter.
objectToSave: string[]. Array of object monikers to be saved on state server. Optional parameter.
batched: boolean. The parameter that determines whether the specified queries must be executed as a single batch. Optional parameter.
sendRequest({parameters}, Json query 1, Json query 2,…) - to execute a batch of JSON queries. Each query executes one of the available operations of BI server. As parameters of the current implementation, one can specify the batched: boolean parameter, which determines whether the specified queries should be executed as a batch
putBin('moniker', FormData) - to upload an image to a document by means of the PutBin operation.
getBin('moniker', indicates whether 'file name' is downloaded) - to get an image from a document by means of the GetBin operation.
Platform.Notification - object containing methods for displaying notifications in the platform style. The list of methods and their signatures:
error('Title', 'Text'). Display error message
warning('Title', 'Text'). Display warning
success('Title', 'Text'). Display success message
info('Title', 'Text'). Display information message.
See also: