Connecting Custom JavaScript-Function

Custom JavaScript function (JS-function) is available for connection:

To connect custom JS-function:

  1. 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:

The path to the folder with installed designer of business applications:

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.

  1. 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"}]

  1. 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

Signatures of Custom JS-functions

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

Available Methods of Platform Namespace Objects in Regular Report/Data Entry Form JS-Functions

JS-function signature of hyperlink/custom button uses the args parameter:

args: {
  moduleId: string;
}

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:

The following objects of the Platform namespace are also available when working with regular reports/data entry forms in JS-functions:

'!module'

'Platform.Managers.MetaBase.connectionId()+'!module'

See also:

Questions and Answers