In Part 1 of series, we covered how to create Image field, upload Image from Dynamics 365 and display Image in Gallery in PowerApp. In this blog we will see how to update Image data back to data source which is Common Data Service for Apps.
I have Edit Form for “Company Products” entity looks like below. We will add data card for Image field and try to update Image data.
- Select your Edit form and click on Fields under Properties tab
- From Data window, select your Image field to be added in Edit Form. Make sure Image field is added with “Add Picture” template
- Image data card consists of two main controls: Image control to display Image and Add Picture control to click Image using Camera or browse image from files.
- Camera option comes when app runs in mobile/tablet. When app runs in browser and user taps on Add Picture control, user will be redirected to browse for image directly
- Tab on Add picture control, select any image and click on Save button on right top corner. New Image will be saved automatically in CDS for Apps
- This was super cool as you didn’t have to write single line of code to click Image using Camera and update back to CDS for apps.
Image Data Card will automatically take care of displaying default Image when Edit Form is loaded, allowing user to click image or select image and finally update image back to data source. Let’s deep dive into Image Data Card control properties to understand this behavior
- As we mentioned above Image Data Card mainly is a combination of Add Picture Control and Image Control. So, when user add Image Data Card on edit form these two controls are automatically added
- Add Picture Control allow user to browse for image from library or take photo using camera
- Once image is selected from Add Picture Control, it will be displayed in Image control using below formula which is set to Image property of Image control. If Add Picture control value is blank it will display default Image of record otherwise Image from Add Picture control
If(IsBlank(AddPicture3.Media), Parent.Default, AddPicture3.Media)
- Let’s look at Image Data Card properties: Default is set to entityimage which will render selected record image to Image control. Update is set to Image4.Image which will update Image from Image control when save button is pressed