Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagejs
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
languagejs
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

id()

String

Retrieves the unique identifier of the master data table.

key()

String

Retrieves the key associated with the master data table.

title()

String

Retrieves the title of the master data table.

columns()

List<MasterDataColumn>

Retrieves a list of columns within the table.

rows()

List<MasterDataRow>

Retrieves a list of rows within the table.

created()

ChangeContextDto

Retrieves the creation context of the table.

modified()

ChangeContextDto

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

key()

String

Retrieves the unique key identifier of the column.

title()

String

Retrieves the title or name of the column.

valueType()

PropertyDataType

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

id()

String

Retrieves the unique identifier of the row.

key()

String

Retrieves the key associated with the row.

title()

String

Retrieves the title of the row.

cells()

List<MasterDataCell>

Retrieves a list of cells contained in the row.

created()

ChangeContext

Retrieves the creation context of the row.

modified()

ChangeContext

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

key()

String

Retrieves the key identifying this cell in the row.

value()

String

Retrieves the value held by this cell.