In this blog we will see how to create new field of image data type in Common Data Service for Apps, followed by image upload in Dynamics 365 and finally display image in Gallery control. We will make use of Company entity we created as part of blog.
Create Image Field:
We will create a new field named “Logo” in Company entity to store company logo image.
- Login to PowerApp web portal. Select Data tab from left navigation and click on Entities
- Select “Company Entity”. Click on Add Field under Fields tab. Enter “Logo” as Display Name, select “Image” as Data type. Click on Done button
- Click on Save Entity
Note: Currently CDS for Apps does not support image data import and you cannot view image data under Data tab.
Upload Image in Dynamics 365:
For every environment in CDS, one Dynamics 365 instance is linked or created and share same database which is Common Data Model. Hence “Logo” field created above will also be visible in Dynamics 365. Let’s set this Logo field as Primary Image of Company entity in Dynamics 365 and upload image for Company records.
- There are 2 ways to navigate to Dynamics 365 instance from within PowerApp portal as below
- Click on gear icon for Settings and select Advanced Customizations. From Advances Customizations, choose Customize
-
- From Settings again, select Admin Centre. In Admin Centre, click on your environment. Click on Dynamics 365 Administration Center link. From Dynamics 365 Admin center, select your instance (with CDS environment name) and click on Open.
- Navigate to Customizations -> Customize the system. Select Company entity from Entities. Select Logo in Primary Image field. Save & Publish
- Navigate to Forms for Company entity and open Main form.
- Click on Form Properties which will open properties window. In Display Tab, check option for “Show image in the form” and click Ok. This will display Logo image field on form so that you can select this field to upload image for each company record
- Save & Publish
- Navigate to Company entity and open any record. Click on image icon beside to record title which will open Edit Image pop-up. Click on Choose file, select image file and click Ok.
- Similarly select image file for all Company records
Display Image in PowerApp Gallery:
- Navigate to PowerApp web portal. Select you App, click on Edit
- Select your Gallery control. Click on Layout in properties window to add image to your Gallery layout
- Click on Refresh button to refresh your data source for new “Logo” field added. From Layout dropdown, select one with image. Select your image in Image drop down which will be entity image.
- Gallery control will be refreshed to display logo images as shown below
- In case Images do not load by default, try using any non-delegable function in Gallery Items property since Image type fields are non-delegable . Refer my blog for more details.