system.kanoa.cmms.addImage(procedureStepCheckId, imageName, imageType, imageDescription, imageBytes, thumbnail, userId)
Inserts a new image record and associates it with a procedure step check. The image and an optional thumbnail are stored as raw byte arrays along with descriptive metadata (name, type, description).
Parameters
procedureStepCheckId 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
imageId Integer
msg String None if success
Example
# Attach a photo captured from a camera/upload component to a procedure step check
procedureStepCheckId = 4218
imageName = "torque-check-photo.jpg"
imageType = "image/jpeg"
imageDescription = "Torque wrench reading after tightening bolt pattern"
# byte arrays typically come from a component such as a File Upload or Camera binding
imageBytes = event.source.parent.getComponent('CameraCapture').primaryImage
thumbnail = event.source.parent.getComponent('CameraCapture').thumbnailImage
userId = system.kanoa.security.getIDPUserId({'userName': 'SYSTEM'})
imageId, msg = system.kanoa.cmms.addImage(procedureStepCheckId, imageName, imageType, imageDescription, imageBytes, thumbnail, userId)
print imageId, msg