Script Editor
Work with your data.
In the overview screen of the script editor, you are able to access and share existing scripts or create new ones. Scripts use datasets and are used for widgets, which will then be part of dashboards. They are also used in automations. To see in which elements a script is used, click on the on the right side of the overview screen and then on show details.
Overview of the Script Editor
This is where you can write our edit your script.
In the additional options, you can make a copy of your script.
Here you can edit your input data (same as in 7.) by selecting datasets.
With the Run button, you can test your script. The results will appear in a table at the bottom of your screen.
Save your script if you want to keep it.
In the General tab in the sidebar name and description can be defined as well as the used programming language.
In the Data and Script tabs in the sidebar, you can add datasets, .rds or .pickle files and other scripts which then can be used in your script (more on that in a later section).
In the Results tab in the sidebar, the result variables are defined (more on that in a later section).
Select a programming language, either R or Python, to write your script with.
Check Activate error logging if you want to save possible errors that occur when your script is run (more in a later section).
Input Data
To add input data to your script you have multiple options depending on what data you want to import. If you want to add datasets to your script, you can use the Edit Data button in the header bar (3.) or the Add Data button in the Data tab. To add scripts, use the Add Data button in the Scripts tab.
After selecting any of these options, a window will popup where you will be shown all available datasets or scripts, depending on which Add Data button you clicked. Find the dataset or script you want to add, enter how many rows of it you want to include in your script in the corresponding input box and click the Add Button next to it. If you're done, click the Finish button to return to the script editor.
Datasets are currently limited to one million rows, scripts with one thousand rows.
Additionally you can add as many datasets as you want, but scripts are limited to a maximum of three.
After you've added datasets or scripts, they will be displayed in the corresponding sidebar tab in tree view. Next to every dataset or script, you will be able to click on the icon to see the columns/results of the selected dataset/script. Next to every column/result you should see a icon - clicking it will add the code to your script necessary to access this column.
For example, let's say we have a dataset called ExampleDataset with a column called Timestamp. Clicking will add the code
ExampleDataset$Timestamp
if you selected R as a language and
ExampleDataset['Timestamp']
if you selected Python. For R the dataset will be imported as data.frame and for Python, it will be a dictionary, where the keys are the column names and the value connected to the key is a list containing the entries of the regarding column.
If you need to check your dataset or your script click on . This will take you either to the dataset in the dataset builder or the script in the script editor.
Results
Navigate to the Results tab in the right sidebar. If you click the Add Result button a window will open. There you can define your result variables. When your script is executed (either by clicking the Run button or because it is used by a widget or automation) the last assigned value of each result variable will be used as output.
Note: If you have multiple result variables all assigned output values need to have the same length because the results will be transformed into some kind of a tabular format.
Executing a script (Run)
You can execute your script with the chosen datasets and result variables to check if the script leads to the expected results.
Below the script, you can see the data of your selected datasets which were used for the script execution in the Datasets tab, and the result of the script on the Output tab.
Notice that you can hide the results window if you need to have a closer look at your script again.
Note: Sub-scripts execution of a main script is made in a synchronous manner (one by one) which means real-time data synchronization between the sub-scripts is not supported at the moment. For example, having a main script with another three subscripts(each with a dataset). Firstly the three subscripts will be called one by one synchronously, and then the main script will be called with the subscripts resulting data.
Error log
If an error occurs, while the script is run from the dashboard and error logging is enabled (Activate Error Logging), error message and other information is stored. Those stored errors can be found in the list view of Script Editor. If user has script write permissions, menu item Error Log will be enabled.
Error info is stored/logged only when run from dashboard. If user runs faulty script from other places like, Script Editor, Widget Editor or API, error is not stored/logged.
Error log contains includes following info:
Timestamp - date and time of error occurred
Executed By - user executing the script (shown as link if having user management permissions)
Script ID - identifier of a script having a run error
Widget ID - identifier of a widget containing the script
Dashboard ID - identifier of a dashboard containing the script
Error Text - reason why error occurred (can be copied to clipboard)
Dashboard URL - full dashboard URL with filters (can be copied to clipboard)