captureImage (Client API reference)

Invokes the device camera to capture an image.

Available for

This method is supported only for the mobile clients.

Syntax

Xrm.Device.captureImage(imageOptions).then(successCallback, errorCallback)

Parameters

Parameter Name Type Required Description
imageOptions Object No An object with the following values:
- allowEdit: Indicates whether to edit the image before saving. Boolean.
- quality: Quality of the image file in percentage. Number.
- height: Height of the image to capture. Number.
- width: Width of the image to capture. Number.
Note: Both the height and width dimensions must be specified if used.
successCallback Function Yes A function to call when image is returned. A base64 encoded image object with the following values is passed to the function:
- fileContent: Contents of the image file. String
- fileName: Name of the image file. String.
- fileSize: Size of the image file in KB. Number.
- mimeType: Image file MIME type. String.
errorCallback Function Yes A function to call when the operation fails.

Return Value

On success, returns a base64 encoded image object with the values specified earlier.

Exceptions

See Web service error codes

Xrm.Device