PowerObjects Blog 

for Microsoft Business Applications


Uploading a Photo from a Canvas App to Dynamics 365 as an Attachment

Post Author: Joe D365 |

In today’s blogpost, we will show you how to upload a camera photo from a Canvas App to Dynamics 365 as an attachment on a particular entity record. 

Depending on the type of business, it can be common for field employees to take a photo quickly on their phone and store it as an Attachment for a specific record in Dynamics 365. For example: we might have a Canvas App to allow an end user take a photo on the Phone; then automatically attach that as an Attachment for a Case Entity. 

Using PowerApps, we created a simple app to display list of Case entity the user owns on a “Case List” Screen; then create another “Photo” Screen that will capture a Photo of the case. Case Entity is only available for Dynamics 365 Customer Service, but this method should be applicable for other entities in Dynamics 365 or Data Flex Pro (Common Data Service). 

Add Camera icon in the CaseGallery to navigate to Photo Capture Screen.  

OnSelect of CameraIcon, write functions as below 


tree view

To create an attachment for a record in Dynamics 365/Data Flex Pro, we need to create a Note (annotation) record with Regarding set as selected Case from the Case Gallery. Make sure we add Notes entity to the Canvas app. 

data sources  

“Photo” Screen to capture Photo includes a few main components as shown below: 

  • TitleTextInput – Text Input control 
  • DescriptionTextInput – Text Input control 
  • CancelButton – Button control 
  • SaveButton – Button control 
  • Camera1 – Camera control 


OnSelect of SaveButton, write a Patch function as below: 

Patch(Notes,Defaults(Notes),{Title:TitleTextInput.Text,Description:DescriptionTextInput.Text,'File Name':"photo.png",Document:Substitute(Substitute(Camera1.Photo,"data:image/png;base64,",""),"data:image/jpeg;base64,",""),'Is Document':'Is Document (Notes)'.Yes,Regarding:CaseGallery.Selected}) 


Note: To create attachments in Dynamics 365 or Data Flex Pro, we need to pass the document body in base64 string. In the canvas app, the camera control gives the image content as base64 with the prefix “data:image/png;base64,” or “data:image/jpeg;base64,”. When creating a Note (annotation) record in Dynamics or Data Flex Pro, we have to remove “data:image/png;base64,” or “data:image/jpeg;base64,”. from the image content 



You can test this On Browser or On PowerApps App in your Phone. Select a case by tap on Camera icon of a case on Gallery. Then fill in some information on Title and Description of the Note and take a Photo by tapping on the Camera. Finally, hit Save. 

attach the photo  

The photo should be created as a new Note of the Case and show in the Timeline. We can download the file and open for viewing. 

D365 record  

final photo upload  



There are several ways to send photo from Canvas App to Dynamics 365/Data Flex Pro as attachment. This is one of the direct ways that can handle inside PowerApps with native Common Data Service connector. 

Don't forget to subscribe to our blog for more helpful tips! 

As always, happy PowerApps’ing!! 

By Joe D365
Joe D365 is a Microsoft Dynamics 365 superhero who runs on pure Dynamics adrenaline. As the face of PowerObjects, Joe D365’s mission is to reveal innovative ways to use Dynamics 365 and bring the application to more businesses and organizations around the world.

Leave a Reply

Your email address will not be published. Required fields are marked *

PowerObjects Recommends