Uncategorized

{Powerapps} Bulk Patch Image column in Dataverse from Canvas App

Requirement
We have to upload images from Powerapps Canvas App in Bulk and need to store those images in Dataverse. It could be used by Field Technician to capture the device images or HR to capture Employees academic files.

Implementation
I have created new Image Column in Dataverse and one Text field to store the ID (ID is optional). I have created new screen in Powerapps where I added Picture control, Label, Text Input, Two buttons as shown below.

User will upload image and they will click on Add To Collection, Once all images are uploaded they will finally click on Patch To Dataverse to store those images in Dataverse.

I have written below code on Select of ‘Add To Collection’ button –

Collect(MyPhotos,{RecordId:TextInput1.Text, Image:UploadedImage1.Image});
Reset(TextInput1);
Reset(AddMediaButton1);

First I am collecting image and Record Id in a collection, then I am resetting both the control.
Then I have written below code on Select of ‘Patch To Dataverse’ button –

ForAll(MyPhotos,Patch(Employees,Defaults(Employees),{‘Record ID’:Value(ThisRecord.RecordId), Image:ThisRecord.Image, ‘Employee Number’:ThisRecord.RecordId}));
Clear(MyPhotos);
Refresh(Employees);

In this code, I am looping through each row in collection and patching it to dataverse. Then I am removing records from collection and refreshing the Datasource to show the latest data in Gallery.

Hope this helps!

3 thoughts on “{Powerapps} Bulk Patch Image column in Dataverse from Canvas App

Leave a Reply

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

WordPress.com Logo

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

Twitter picture

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

Facebook photo

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

Connecting to %s