Skip to main content

system.kanoa.cmms.addWorkOrderEventImage(workOrderEventId, imageName, imageType, imageDescription, imageBytes, thumbnail, userId)

Creates a new image record attached to a work order event, storing the full-resolution image bytes alongside an optional thumbnail, a name/type/description for the image, and a userId for the audit trail. This is typically used to attach technician-captured "before" or "after" photos (e.g. from system.cam or a file upload component) to a work order event. On success, the new workOrderEventImageId is returned; on failure, an error message is returned instead.


Parameters

workOrderEventId Integer: Id of the procedureStepCheckId
imageName String: Name of image
imageType String: Type of image
imageDescription String: Description of image
imageBytes byteArray: The image in byteArray format
thumbnail byteArray: Thumbnail of image in byteArray format
userId Integer:Id of the user executing the function


Returns

workOrderEventImageId Integer
msg String None if success


Example

# Capture a photo from an Ignition camera component and attach it
# to a work order event as a "before repair" image, along with a
# generated thumbnail.

workOrderEventId = 4821
userId = system.kanoa.security.getIDPUserId({'userName': 'SYSTEM'})

# imageBytes/thumbBytes might come from system.cam.getImage() or a file upload component's .data property
imageBytes = system.file.readFileAsBytes('C:/temp/repair_before.jpg')
thumbBytes = system.file.readFileAsBytes('C:/temp/repair_before_thumb.jpg')

imageEventId, msg = system.kanoa.cmms.addWorkOrderEventImage(
workOrderEventId,
'repair_before.jpg',
'JPEG',
'Before photo - hydraulic leak on pump housing',
imageBytes,
thumbBytes,
userId
)
print imageEventId, msg