LBOUtilities#
Note
This is advanced documentation regarding a scope that can be accessed when executing a step of type Script.
These methods provide utility functions for interacting with LBO (Lightweight Business Objects) data and performing various operations such as IoT entity retrieval, state model handling, and master data processing.
iotEnabledEntities#
iotEnabledEntities(fields?: string[]): Promise<any[]>
Retrieves all IoT-enabled entities from the system. Filters the entities based on the presence of ConnectIoTEnabled and optionally strips unwanted fields.
fields(optional): An array of field names to retain in the resulting objects.
A filtered list of IoT-enabled entities.
entityTypesWithStateModel#
entityTypesWithStateModel(entityTypes?: string[], stripEntity?: boolean, fields?: string[]): Promise<any[]>
Retrieves entity types that have associated state models and optionally filters or strips their properties.
entityTypes(optional): A list of entity type names to filter by.stripEntity(optional): Whether to strip unwanted properties from the result.fields(optional): A list of fields to retain when stripping entities.
A list of filtered entity types with state models.
{
"name": "Example EntityTypesWithStateModels",
"type": "Script",
"resultKey": "iotEntityTypesWithStateModels",
"settings": {
"script": [
"(async () => {",
" const entityTypes = await this.iotUtilities.allEntityTypesFromController(entityInstance);",
" const entityTypesWithStateModels = await this.lboUtilities.entityTypesWithStateModel(entityTypes, true);",
" if(entityTypesWithStateModels == null || entityTypesWithStateModels.length == 0) {",
" throw new Error('No State Model found for Entity Types associated with this controller');",
" }",
"return entityTypesWithStateModels;",
"})()"
]
},
"next": "SelectEntityType"
}
entityTypeStateModels#
entityTypeStateModels(entityTypeName: string): Promise<Map<string, StateModelStateCollection>>
Retrieves state model names and their associated states for a given entity type.
entityTypeName: The name of the entity type to retrieve state models for.
A map where keys are state model names, and values are state collections.
{
"name": "Example EntityTypeStateModels",
"type": "Script",
"resultKey": "iotEntityTypeStateModels",
"settings": {
"script": [
"(async () => {",
" this.answers.stateModels = await this.lboUtilities.entityTypeStateModels(this.answers.iotEntityType.Name);",
" const stateModelKeys = Array.from(this.answers.stateModels.keys());",
" return this.lboUtilities.convertArrayOfStringsToEnum(stateModelKeys);",
"})()"
]
},
"next": "CheckStateModels"
}
stripEntity#
stripEntity(obj: any, fields?: string[]): any
Strips all properties from an object except for the specified fields.
obj: The object to strip properties from.fields(optional): An array of fields to retain. Defaults to['$type', 'Name'].
A new object containing only the specified fields.
convertArrayOfStringsToEnum#
convertArrayOfStringsToEnum(values: string[]): { Id: string, Name: string }[]
Converts an array of strings into a format suitable for enumeration.
values: An array of strings to convert.
An array of objects where each object has Id and Name properties.
{
"name": "Example EntityTypeStateModels",
"type": "Script",
"resultKey": "iotEntityTypeStateModels",
"settings": {
"script": [
"(async () => {",
" this.answers.stateModels = await this.lboUtilities.entityTypeStateModels(this.answers.iotEntityType.Name);",
" const stateModelKeys = Array.from(this.answers.stateModels.keys());",
" return this.lboUtilities.convertArrayOfStringsToEnum(stateModelKeys);",
"})()"
]
},
"next": "CheckStateModels"
}
createAndPerformMasterdata#
createAndPerformMasterdata(masterdata: object, masterdataName?: string): Promise<void>
Creates a master data package and performs it immediately.
masterdata: The master data object to process.masterdataName(optional): A custom name for the master data package. If not provided, a unique name is generated.
void
createMasterdata#
createMasterdata(masterdata: object, masterdataName?: string): Promise<MasterDataPackage>
Creates a master data package.
masterdata: The master data object to process.masterdataName(optional): A custom name for the master data package. If not provided, a unique name is generated.
A MasterDataPackage object representing the created package.
performMasterdata#
performMasterdata(masterdataPackage: MasterDataPackage): Promise<void>
Performs a master data package by loading its data into the system.
masterdataPackage: The master data package to perform.
void