Skip to main content

system.kanoa.cmms.importWorkOrderTemplates(paramsDict, userId)

Imports a file from exportWorkOrderTemplates, all or nothing: if any template has an error, nothing is written. References are matched by natural key. A missing asset, priority, schedule type, condition or counter is an error; a missing maintenance type/sub type, procedure (from the file), data type, engineering unit or pick list is created; a missing alert group is left off (with a warning). Users are not matched: a new template is requested by the importing user and unassigned, and an overwritten one keeps its own. An existing procedure with the same path is reused. Every imported template is saved as Draft. Run with dryRun first to preview


Parameters​

paramsDict Dictionary

- dataDictionary or StringThe export file - the whole file or just its 'data' - as a dictionary or JSON string
- onDuplicateStringNot required. What to do when a template with the same maintenance type and title exists: 'rename' (default, appends a timestamp), 'skip', or 'overwrite' (replaces its fields, schedule, conditions and alert groups; an error if more than one template matches)
- dryRunBooleanNot required. Defaults to True: reports what would happen and writes nothing. Pass False to import

userId Integer: Id of the user executing the function


Returns​

Dictionary {'passed' (Boolean), 'dryRun' (Boolean), 'message' (String), 'results': [{'title', 'importedTitle', 'action' ('create', 'rename', 'overwrite' or 'skip'; None if the template has errors), 'workOrderId' (None in a dry run), 'warnings' (List of String), 'errors' (List of String)}]}


Example​

paramsDict = {'onDuplicate': 'rename', 'dryRun': True, 'data': {}}
userId = 5
result = system.kanoa.cmms.importWorkOrderTemplates(paramsDict, userId)