Skip to main content
Version: V2 (Ignition 8.1)

system.mes.material.exportReasonCodesAsJson

Description

Exports all or selected material reason codes as raw bytes in JSON format (UTF-8 encoded). Streams material reason code data from the database and formats it as JSON. When idsOrCodes is omitted, all material reason codes are exported.

Permissions

This method requires the MATERIAL.READ.GET permission.

Syntax

system.mes.material.exportReasonCodesAsJson()
system.mes.material.exportReasonCodesAsJson(idsOrCodes=["SCRAP"])

Parameters

ParameterTypeNullableDescription
idsOrCodesString[]YesThe ids or codes of the material reason codes to export. Omit to export all.

Returns

A byte array (byte[]) containing the raw byte data of the JSON export.

Code Examples

Perspective

jsonBytes = system.mes.material.exportReasonCodesAsJson()
system.perspective.download("material-reason-codes.json", jsonBytes)

Script Console

jsonBytes = system.mes.material.exportReasonCodesAsJson()
path = system.file.saveFile("material-reason-codes.json")
if path is not None:
system.file.writeFile(path, jsonBytes)