Skip to main content
Version: V2 (Ignition 8.1)

system.mes.material.exportReasonCodesAsCsv

Description

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

Permissions

This method requires the MATERIAL.READ.GET permission.

Syntax

system.mes.material.exportReasonCodesAsCsv()
system.mes.material.exportReasonCodesAsCsv(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 CSV export.

Code Examples

Perspective

csvBytes = system.mes.material.exportReasonCodesAsCsv()
system.perspective.download("material-reason-codes.csv", csvBytes)

Script Console

csvBytes = system.mes.material.exportReasonCodesAsCsv()
path = system.file.saveFile("material-reason-codes.csv")
if path is not None:
system.file.writeFile(path, csvBytes)