Skip to main content

system.kanoa.cmms.addWorkType(workTypeInfo, userId)

Adds a new work type to the system (e.g. "Design", "Repair") for classifying the kind of work a technician performed on a work order event, logged via addWorkOrderEventTechnician. All keys in workTypeInfo are required unless otherwise stated as this function does not perform a partial insert. On success, the newly generated work type id is returned; on failure, an error message is returned instead.


Parameters

workTypeInfo Dictionary

- enabledBooleanNot required. Defaults to True if not passed
- sortOrderIntegerNot required. Defaults to 0 if not passed
- workTypeColorStringNot required. i.e '#FF0000'
- workTypeNameStringName of work type

userId Integer:Id of the user executing the function


Returns

workTypeId Integer
message String None if success


Example

# Create a new "Design" work type
workTypeInfo = {
"workTypeName": "Design",
"workTypeColor": "#2E86C1",
"enabled": True,
"sortOrder": 4,
}
userId = system.kanoa.security.getIDPUserId({'userName': 'SYSTEM'})
workTypeId, message = system.kanoa.cmms.addWorkType(workTypeInfo, userId)
print workTypeId, message