getPicture Function

The getPicture function provides access to the device's default camera application or device's photo library for retrieving a picture asynchronously.

If the SourceType is CAMERA or BOTH, the getPicture function opens the device's default camera application (if the device has a camera) so the user can take a picture. Once the picture is taken, the device's camera application closes and the mobile workflow application is restored. If the device does not have a camera application, the function reports that it is not supported.

Function Description
getPicture(onGetPictureError, onGetPictureSuccess, options)
  • onGetPictureError – If an error occurs with the picture chooser or the device camera, an appropriate error code is returned in the onGetPictureError function.
  • onGetPictureSuccess (fileName, response) – the return value is sent to this function
    Note: The function defined must use the format onGetPictureSuccess(fileName, response). fileName is required.
  • options – picture options:
  • PictureOption.SourceType
    • CAMERA – specifies the built-in camera as the image source where image content is not persisted by the device
    • PHOTOLIBRARY –specifies the photo library as the image source where image content is already persisted on the device
    • BOTH –Specifies the built-in camera as the image source where image content is persisted by the device
      Note: The BOTH source type is not supported on Android or Windows Mobile.
  • PictureOption.DestinationType
    • imageUri – returns uniform reference identifier for the image
    • imageData – Deprecated. It is recommended that you use imageUri.
onGetPictureError(errorcode) This is a user-defined function. Error codes include:
  • PictureError.NO_ERROR = 0;
  • PictureError.NOT_SUPPORTED = -1; – getPicture() not implemented, camera not present,
  • PictureError.IN_PROGRESS = -2; – getPicture() has already been requested but has not yet completed.
  • PictureError.USER_REJECT = -3; – the user has canceled the request.
  • PictureError.BAD_OPTIONS = -4; – supplied options were not recognized.
  • PictureError.TOO_LARGE = -5; – the returned image size was too large to be handled by JavaScript
  • PictureError.UNKNOWN = -6; – an unknown error occurred.
onGetPictureSuccess(fileName, response) This is a user-defined function. The return value is sent to the onGetPictureSuccess function, in one of the following formats, depending on the GetPicture options you specify. You can take this value and set it as a value into the MessageValueCollection function.
  • File name – file name of the image
  • response – the response will be either a Base64-encoded JPG string or a URI.
In the code, onGetPictureSuccess(fileName, response) will be used as onGetPictureSuccess(fileName, imageURI) or onGetPictureSuccess(fileName, imageData ). The parameter should coincide with the PictureOption.DestinationType. There are two conditions:
  • destinationType: PictureOption.DestinationType.IMAGE_URI – returns a uniform reference identifier for the image onGetPictureSuccess(fileName, imageURI)
  • destinationType: PictureOption.DestinationType.IMAGE_DATA – returns Base64-encoded string onGetPictureSuccess(fileName, imageData )