...
Code Block | ||
---|---|---|
| ||
let log = context.getLogger(); log.info("Guard currently executing"); |
Accessing Master Data
Scripts have the capability to access and utilize master data, which are tables of fixed data independent of the concept units. Master data provides a stable dataset that scripts can rely on for performing various operations, such as validations and computations.
Example how to Access Master Data
To access master data within a script, the script can retrieve a master data table using the execution context provided by the internal JavaScript API. Here is an example of how to access and log information from master data in a guard script:
Code Block | ||
---|---|---|
| ||
let log = context.getLogger();
let masterDataTable = context.getMasterDataTable("masterDataKey");
log.info("Master data table title: " + masterDataTable.title());
let masterDataRow = masterDataTable.rows()[0];
log.info("Master data row title: " + masterDataRow.title());
log.info("Master data row cell 1 value: " + masterDataRow.cells()[0].value());
log.info("Master data row cell 2 value: " + masterDataRow.cells()[1].value());
|
In this example, the script retrieves a master data table using a key, and then accesses data from the first row of the table. This data can be used to perform checks, inform calculations, or influence script behavior based on the stable data provided.
This ability to interact with master data ensures that your scripts can operate with a consistent set of data, crucial for maintaining the integrity and reliability of operations within the application.
Available methods to Access Master Data
Below is a description of the methods available on the MasterDataTable
object. This object encapsulates the structure and data of a master data table, which includes its columns and rows.
Method | Return Type | Description |
---|---|---|
|
| Retrieves the unique identifier of the master data table. |
|
| Retrieves the key associated with the master data table. |
|
| Retrieves the title of the master data table. |
|
| Retrieves a list of columns within the table. |
|
| Retrieves a list of rows within the table. |
|
| Retrieves the creation context of the table. |
|
| Retrieves the last modified context of the table. |
Below is a table describing the methods available on the MasterDataColumn
object, which represents a column within a master data table.
Method | Return Type | Description |
---|---|---|
|
| Retrieves the unique key identifier of the column. |
|
| Retrieves the title or name of the column. |
|
| Retrieves the data type of the column's values. |
Here's a table that outlines the methods accessible on the MasterDataRow
object, which encapsulates a row within a master data table.
Method | Return Type | Description |
---|---|---|
|
| Retrieves the unique identifier of the row. |
|
| Retrieves the key associated with the row. |
|
| Retrieves the title of the row. |
|
| Retrieves a list of cells contained in the row. |
|
| Retrieves the creation context of the row. |
|
| Retrieves the last modified context of the row. |
Lastly, the following table describes the methods on the MasterDataCell
object, which represents individual cells within a master data row.
Method | Return Type | Description |
---|---|---|
|
| Retrieves the key identifying this cell in the row. |
|
| Retrieves the value held by this cell. |