system.mes.personnel.exportDepartmentsAsJson
Description
Exports all or selected departments as raw bytes in JSON format (UTF-8 encoded).
Streams department data from the database and formats it as JSON, where each object corresponds to a
DepartmentImportDTO. When idsOrPaths is omitted, all departments are exported.
Permissions
This method requires the PERSONNEL.READ.GET permission.
Syntax
system.mes.personnel.exportDepartmentsAsJson()
system.mes.personnel.exportDepartmentsAsJson(idsOrPaths=["Enterprise/Site/Maintenance"])
Parameters
| Parameter | Type | Nullable | Description |
|---|---|---|---|
idsOrPaths | String[] | Yes | The ids or paths of the departments to export. Omit to export all. |
Returns
A byte array (byte[]) containing the raw byte data of the JSON export (UTF-8 encoded).
Code Examples
Perspective
jsonBytes = system.mes.personnel.exportDepartmentsAsJson()
system.perspective.download("departments.json", jsonBytes)
Script Console
jsonBytes = system.mes.personnel.exportDepartmentsAsJson()
path = system.file.saveFile("departments.json")
if path is not None:
system.file.writeFile(path, jsonBytes)