Fun with Power Apps!

Bill Cat loves Power Apps
Bill Cat loves Power Apps

For the past couple of weeks, I’ve had my Power Apps hat back on. We are designing two model-driven apps for government and the service industry.

Through many hours of bashing my head against the keyboard, trial and error and endless searching, here are some solutions I’ve found for some vexing app problems.

A view with everything on or before today’s date

This one I forgot about from my old CRM days with Advanced Find. No history lesson here, but thank you Frank Lee for your blog post on how to do this.

Dataverse view filters

On the Canvas app that goes along with the model-driven app, this works perfectly to show the app user only the records that are today or earlier and not completed. Yay!

View in Canvas app with all items today or before

Attaching images to the notes of a record

Who knew that attaching images into Dataverse was so strange. I sure didn’t realize it.

The goal was to attach an image to the pickup record using the Notes table. In the canvas app, there is the ability to attach a photo using the add image control (thanks Matthew Devaney for talking me out of using the camera control in one of your blog posts!) — this lets the user either select a file on the device or use the device’s camera to get a much better quality photo.

Canvas app take picture

I struggled and struggled with this because the record would get created and the image attached, but you couldn’t open it! It was all because of the encoding!

Thanks to the Power Apps community again and a response from Jens Kofod, there was a forum thread that kept coming up in my searches about converting and saving the pen input. So, I tried it, messed around with the code and IT WORKED!

First, I created a variable and set the value to the JSON format and include the binary data.

Set(varImage64, JSON(TakePictureUploadedImage.Image, JSONFormat.IncludeBinaryData));

Then I created a second variable to strip out the characters at the beginning and end.

Set(varImage64Edit, Mid(varImage64, 25, Len(varImage64)-25));

This statement confused me a bit initially and I had to play with the starting position of the Mid() function and the number of characters to subtract from the Len() function.

Then a Patch command to add it to the Notes table regarding the pickup on the screen.

Patch(Notes,Defaults(Notes),{Title:"Picture at Location",Description:"Picture of location condition taken on " & Now() & If(txtTakePictureAdditionalNotes.Text="","","

" & "Additional notes:" & "
" & txtTakePictureAdditionalNotes.Text),'File Name':"photo.jpg",Document:varImage64Edit,'Is Document':'Is Document (Notes)'.Yes,Regarding:PickupGallery.Selected});


Going back to Power Apps, there’s our note and attached image!

Note in Power Apps with picture attached

I had just finished breakfast.

Photo attached to Notes in Power Apps


Changing the status when saving a record into Dataverse

This one was the most annoying to figure out — but thanks to the Power Apps Community and some additional trial and error, you can do it!

The list of pickups is a gallery view based on a view in Dataverse. By default, an active record’s Status is called “Active” and the associated Status Reason is also called “Active.” For an inactive record, an inactive record’s status is called “Inactive” and the associated Status Reason is just “Inactive.” Easy.

I’ve changed the active status reason to be “Pending” and the inactive status reason to be “Completed” instead.

Once the pickup is completed, I just wanted the user to hit the Submit button and the record is marked complete — changing the status to “Inactive” and the status reason to “Completed”. This would take it off the pending pickups list, lock down all the fields and just be a better user experience for everyone.

Submit button

So, how to do?

It is much easier than I thought. All of these are put in the OnSubmit action of the button to complete the pickup.

First we submit the data entered in the form:


Then we run a Patch command to immediately change the status of the submitted record:

Patch(Pickups, PickupGallery.Selected, {statecode: 'Status (Pickups)'.Inactive, statuscode: 'Status Reason (Pickups)'.Completed});


These seem really simple, but they were huge accomplishments for me. Am constantly amazed at what we can do with Power Apps and a little bit of code.

Leave a Comment

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