Skip to main content

system.mes.operation.importFromJson

Description

Imports Operations from a JSON file provided as a string or as raw bytes. The service layer will parse the JSON content and create or update operation entities based on the 'name' and 'location' columns.

Recommended to export at least one pre-existing operation to JSON using the Export Operations functionality to ensure the correct format of the JSON file.

Syntax

system.mes.operation.importFromJson(importString)
system.mes.operation.importFromJson(importBytes)

Parameters

Either a string or bytes array representing the JSON content.

ParameterTypeDescription
importStringStringThe JSON content as a string.
importBytesPyArrayThe JSON content as raw bytes.

Returns

The number of operations successfully imported or updated.

Code Examples

Here is an example of how to use the importFromJson method in the context of a Perspective File Upload Component onFileReceived event handler. Reference Perspective - File Upload Scripting for more information on the onFileReceived event handler.

Bytes

def runAction(self, event):
jsonBytes = event.file.getBytes()
system.mes.operation.importFromJson(jsonBytes)

String

def runAction(self, event):
jsonString = event.file.getString()
system.mes.operation.importFromJson(jsonString)