A custom JS-function can be called from a report in the Dashboards and Reports tools.
To call a custom JS-function from a report:
Add a custom JS-function into the main tool file. A detailed description is given below.
Set up custom JS-function call. The setup depends on the tool in use:
Dashboards. Add the Button control to the dashboard and set up executing the JS-Function Call command for it.
Reports. A custom JS-function can be called in a regular report for:
Dimension element in table visualizer sidehead/heading. Set up detailing: specify a custom JS-function that will be executed on clicking the main button of the mouse on the dimension element.
Random cell in report. Specify that cell text must be a hyperlink and set up the Execute a Procedure/Function operation including setting a custom JS-function.
Save the report.
The main tool file for the Dashboards tool is dashboard.html, the main tool file for the Reports tool is reporter.html. The files are located in the App folder with installed Foresight Analytics Platform web application.
A custom JS-function can be added as a single file or inserted into the main tool file. Consider adding the myFunc() function.
To add a JS-function as a single file:
Create a JS-file and write custom function code in it. For example, create the Func.js file with the following code:
function myFunc() {
alert("Example of calling custom JS-function from file");
}
Add a link to the created file to the <head> tag of the main tool file. For example, if JS-file and main tool file are located in the same folder, the link will look as follows:
<script src="Func.js" type="text/javascript"></script>
Save changes in the main tool file.
To insert JS-function to the main tool file:
Add the <script> tag with JS-function text into the <head> tag of the main tool file. For example:
<script type="text/javascript">
function myFunc() {
alert("Example of calling custom JS-function");
}
</script>
Save changes in the main tool file.
See also:
Questions and Answers | Dashboards: Button Commands Control | Table Visualizer: Actions on Opening Hyperlink | Table Cell: Hyperlink Action