How to capture photo and update in Dynamics 365 for Phones App using Javascript CRM Online V9.X?

captureImage invokes the device camera to capture an image


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


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.

Note: This method is supported only for the mobile clients. (Dynamics 365 for Phones App in Tablet and Mobiles)


Capture Photo button is created on Account form and OnClick of the button below function CaptureImage configured.

function CaptureImage() {
 function success(result) {
 // Update Image
 updateImage(, result.fileContent);
 function (error) {
 // Show Error
 Xrm.Utility.alertDialog("Error :" + error.message, null);

// This function will update the Image to Account record
function UpdateImage(accountGuid, ImageContent) {
 // define the data to update a record
 var data =
 "entityimage": ImageContent
 // Update the record
 Xrm.WebApi.updateRecord("account", accountGuid, data).then(
 function success(result) {
 Xrm.Utility.alertDialog("Account Image updated", function () {
// Reload Account form to show the updated Image
 function (error) {
 Xrm.Utility.alertDialog("Error while updating Account Image : " + error.message, null);
 // handle error conditions


1.Open Dynamics 365 for Phones App in Mobile or Tablet.

2.Navigate to Accounts and open any Account record.

3.Tap on Capture Photo button. System or Mobile Inbuilt Camera will be opened and click on Camera icon to capture the photo.

Capture Photo

4. Once photo is captured and saved, you will see the below message. Tap on OK to open the Account record to see the updated image.

Captured Image Updated Message

Hope you learned this new feature :):):)


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.