captureImage (Client API reference)

Applies to Dynamics 365 for Customer Engagement apps version 9.x

Invokes the device camera to capture an image.

Syntax

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

Parameters

Parameter Name Type Required Description
imageOptions Object No An object with the following attributes:
- allowEdit: Indicates whether to edit the image before saving. Boolean.
- height: Height of the image to capture. Number.
- preferFrontCamera: Indicates whether to capture image using the front camera of the device. Boolean.
- quality: Quality of the image file in percentage. Number.
- width: Width of the image to capture. Number..
successCallback Function Yes A function to call when image is returned. A base64 encoded image object with the following attributes 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 attributes specified earlier.

Remarks

This method is supported only for the mobile clients.

Xrm.Device