# Script Engine

The Script Engine offers you the possibility to edit data in BuildingPro Suites using Python and SQL scripts.

What is special about scripts is that scripts are applied to the data repeatedly and at regular intervals.

{% hint style="info" %}
For simple data manipulations, e.g., adding values, the ↗ Calculator can be used.
{% endhint %}

## Application Scenarios

Here are some typical and advanced use cases in which scripts can be used effectively:

#### Evaluate and Reset Counters

Counters, such as person counters, must be reset regularly to ensure accurate values. Scripts can be programmed to automatically reset these counters at set times.

#### Determine Maximum Values

Scripts can be used to determine the highest value from a series of values and to highlight or further process it.

#### Machine Learning Models and Predictions

An advanced application scenario involves the integration of machine learning models. Scripts can be used to make predictions based on historical data, perform optimizations, or recognize correlations between different data sets.

#### Processing of Attachments

Scripts can be programmed to automatically scan attachments when they are uploaded and write the extracted data directly to the corresponding asset.

#### Plausibility Checks

Another application is the plausibility check of data. A script can check whether the data is within certain limits. If the data is plausible, the value is set to 0, otherwise to 1.

## Accepted Languages

Scripts can be written in *Python* or *SQL*.

## Open Script Overview

<div data-full-width="true"><figure><img src="https://3489494878-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9GvUpaatBiReR43XFSMg%2Fuploads%2FQcAZZtdUQJNbTh1IIZPH%2FDocs%20ScriptEngine%201.png?alt=media&#x26;token=5e6c06de-0916-4b6d-a4d8-62db66961b86" alt=""><figcaption></figcaption></figure></div>

1. Click on **Engineering** **\[A]**
2. Click on **Script Engine** **\[B]**

   ▷The Script Overview opens

{% hint style="info" %}
BuildingPro Suites comes with integrated scripts, so-called *system scripts*.

These scripts are only visible to [System Owners](https://docs.buildings.ability.abb/collection/mandatory-base/platform-core/workspace-and-identity/roles#system-roles).

For all other users, these system scripts do not appear in the Script Overview. System scripts can be recognized by the fact that the edit option **\[Q]** is grayed out and unavailable.
{% endhint %}

### Details

In the Script Engine, you have the following options:

<table data-full-width="true"><thead><tr><th width="67.20001220703125">Element</th><th width="199.5999755859375">Title</th><th>Details</th></tr></thead><tbody><tr><td><strong>[C]</strong></td><td>"Scripts" section</td><td>Displays an overview of all already created scripts</td></tr><tr><td><strong>[D]</strong></td><td>Search</td><td>Opens the "Search" sidebar. There you can search specifically for individual scripts</td></tr><tr><td><strong>[E]</strong></td><td>Create new script</td><td>Click to create a new script</td></tr><tr><td><strong>[F]</strong></td><td>Pause/activate script</td><td>Click to pause a running script or to reactivate a paused script</td></tr><tr><td><strong>[G]</strong></td><td>Script status</td><td>Shows whether a script is activated ("Active") or paused ("Inactive")</td></tr><tr><td><strong>[H]</strong></td><td>Name</td><td>Shows the name of the script. The name of the script is assigned by the user when the script is created. The name can be changed afterward.</td></tr><tr><td><strong>[I]</strong></td><td>Shows the description of the script.</td><td>The description of the script is assigned by the user when they create the script. The name can be changed afterward.</td></tr><tr><td><strong>[J]</strong></td><td>Type</td><td>Shows whether the script was created in SQL or Python.</td></tr><tr><td><strong>[K]</strong></td><td>Errors</td><td>Shows whether the script has errors</td></tr><tr><td><strong>[L]</strong></td><td>Repeat</td><td>Shows the <a href="configure-scripts#raster">↗ raster</a> that was selected for this script.</td></tr><tr><td><strong>[M]</strong></td><td>Last run</td><td>Shows when the script last ran.</td></tr><tr><td><strong>[N]</strong></td><td>Next run</td><td>Shows when the script will run next.</td></tr><tr><td><strong>[O]</strong></td><td>Duration</td><td>Shows how long the last run took.</td></tr><tr><td><strong>[P]</strong></td><td>Delete</td><td>Deletes the selected script.</td></tr><tr><td><strong>[Q]</strong></td><td>Edit</td><td>Click to edit the script. Calls up the menu <a href="script-engine/configure-scripts">↗ Configure script.</a></td></tr><tr><td><strong>[R]</strong></td><td>Errors</td><td>Shows that there is an error with the script.</td></tr></tbody></table>

## Create a New Script

1. Open the Script Overview as described in [↗ Open Script Overview](#open-script-overview)
2. Click on **\[E]**

   ▷ The window **\[S]** opens
3. In field **\[T]**, give the script a name.

   ◈ This name will later be displayed in field **\[H]**
4. In field **\[U]**, choose whether the script is written in Python or SQL
5. Click on **\[V]** to create the script

   ▷The "Configure Script" menu opens
6. Continue as described in chapter [↗ Configure scripts](https://docs.buildings.ability.abb/collection/platform/platform-core/script-engine/configure-scripts)
