blog.atwork.at

news and know-how about microsoft, technology, cloud and more.

Tips for PowerApps-A drivers logbook

PowerApps are a great way to accomplish simple tasks by end users. A new PowerApp is usually done in minutes (if the underlying data source is existing and working). Nevertheless, it often takes much more time to polish the app and to find and modify details. So I decided to post from time to time some tips when stumbling upon any topics in PowerApps.

A driver's log

I wanted to use a very simple custom SharePoint Online list to allow colleagues to log their travels with a company car. At every destination, the user shall simply protocol his location and the mileage, and optional some information about the customer or the appointment. Very little fields, just to keep it handy.

This was the goal - and the result: Three (four) screens.

The list shows all records of the current user, sorted by mileage descending, with driver, if the trip was private or for work, the date and the comment. The further screens show one record and allow to view, edit or create a new record.

image image

image image

Ok, I will play with the colors.. but I wanted to use the company colors. And I added an About page as well. Tip: Get nice icons at icons8.com.

Filtering the list

Anyway, here are the important parts. I wanted to accomplish the following appearance:

  • The list should be filtered just for the current user, only his own records should be visible
  • The list should be ordered by mileage descending, so that the last mileage is on top
  • The text filter should filter for locations or the title column

AFAIK, it's still not possible, to use SharePoint views as data source (but it's on the product team's roadmap). My data source name is "Fahrtenbuch" (german for driver's log), coming from a SharePoint list.

SNAGHTML5ad380c

Doing the filtering for the current user was the most important part. To make it quick: This came out to be the solution for that requirements:

Setting the collection Items property: Instead of (the generated filter)

SortByColumns(Search(Fahrtenbuch, TextSearchBox1.Text, "Driver","Location","Title"),
"Driver", If(SortDescending1, Descending, Ascending))

I used
SortByColumns(Filter( Fahrtenbuch, Lower(Office365Users.MyProfile().DisplayName) = Lower( Driver)
&& ( TextSearchBox1.Text in Location  || TextSearchBox1.Text in Title )),
"Milage", If(SortDescending1, Ascending,Descending))

Voila. The article Filter, Search, and LookUp functions in PowerApps helped!

Setting defaults

I added the data source for Office 365 users to get data about the current user. Setting the default for the current user is easy: Edit the properties of the data card in the edit form and set the Default value to Office365Users.MyProfile().DisplayName.

image

The same goes for the date. Here II used Today() as default value. Done.

So, when clicking the Plus icon in the list, the default values are set automatically, which saves time.

SNAGHTML5b1add5

Share it!

After checking that the app does what it should, share it. I decided that every user in my organization is able to use this wonderful app. This is done at the https://web.powerapps.com/environments website.

image

Enjoy your new PowerApp!

Comments (1) -

  • Pat

    2/10/2017 12:33:19 AM |

    Hi, I'm wondering how you got the Powerapps to filter by current user and allow the current user to be the default value for "Driver". I followed your steps and also connected the Office 365 user Data Source, but still getting errors saying, "The property expects Record values, but this rule produces incompatible text values".

    Is there something I am missing or a step not mentioned on your blog?

    This article is great and exactly what I need to produce. The only road block is that I only want users to see their own records as you got working in your case.

    Thanks.

Pingbacks and trackbacks (4)+

Loading