<img height="1" width="1" style="display:none" src="https://www.facebook.com/tr?id=931099456970389&amp;ev=PageView&amp;noscript=1">

powerappslogoIf you’ve been keeping up with my recent posts, I’ve been building a shout out application for our HR Manager. In this episode, my next step is to build a gallery that represents our activity feed. We want to have the ability to say, show me all the shoutouts, just my shoutouts or the shoutouts I’ve given to others.

To do this, I’ll need to do an ‘If...Then’ statement which can lead to some challenges with SharePoint delegation in PowerApps. Let’s begin:

  • I’m going to focus on the activity feed where the user can select from 3 options (see all shoutouts, my shoutouts, or given shoutouts) and my If...Then statement will derive our filter based on that choice.
  • I’ll begin by adding a vertical gallery and make the data source the Culture ShoutOuts list from SharePoint that I created in my previous post. I notice that some of the things I thought I had available to me are not here, like the sample image does not show the image of the person inside the SharePoint gallery.
  • To get to that picture, I type in Thisitem.Nominated. in the code field which then gives us a drop-down of items as we’re using the People Picker inside SharePoint. People Picker can store multiple different types of fields all packed inside of one field. In this case, we’re storing our name, email address, department, photo, etc. By adding a dot at the end of that People Picker field, I can drill into other things.
  • Once I get the person's picture, I add values to find the title and date of the shoutout and its cultural category.
  • My next step is to make this easier to see who I’ve given shoutouts to and who has given shoutouts to me. To do that I’ll choose a drop-down control with three values inside it.
  • I could point to a table that has those values or in this case I create a table on the fly. In the code bar I add values for All, Sent and My Shoutouts.
  • Now I want to add my If statement. If I select Sent Shoutouts, I only want to see the ones I sent or that I’m part of. First, I select the gallery and select my data source, and the items in the gallery will be filtered based the value selected.
  • Now I add my If statements. I create a statement in the code bar that says IF the value of the drop-down box is equal to my shoutouts then tell it what you want it to do. I also add a few conditions and filters inside that statement. (see video for the exact coding)
  • The main ‘gotcha’ that you’ll have is the People Picker field is an embedded field and that will cause some issues. You will get a delegation warning; SharePoint will take in that entire list and then apply the filter on the client side instead of the server side. SharePoint allows an equal sign to be delegated because it is an embedded field. When you use things like the People Picker, it won’t be as clean as it could be.
  • The workaround I did for this is I also wrote the email address to a second field and change up my code to point to that field, so I no longer get that delegation warning.
  • Something to note is you will be capped at 500 events if you do this. But if you have over 500 records in your SharePoint list, you can go over to File and App settings, go under Advanced and change the setting for how many rows you want to allow for non delegatable events (typically not over 2000).
  • Another delegation problem I’m having is the nominated by email part of my statement (.email) because the Office function there is giving me some grief. The answer here is to store that in a startup variable that has that email inside of it. If we use the variable here instead of that Office function, then it will work.
  • If you want more detail on changing the code to fix this issue be sure to check out my demo.

If...Then statements are the simple part but the issues you’ll run into is with the delegation part in this process inside of PowerApps. In general, if it’s a row by row operation, it will trigger a delegatable event, so you’ll need to be aware of that and know ways to work around it.

In the next post I’ll make our HR application fun by adding some gamification into our shoutout app. I’ll show you how to build small reports with the GroupBy and Sum functions to create a leader board in PowerApps.

Just starting out with PowerApps? How about learning it for FREE? In partnership with Microsoft, Pragmatic Works’ virtual App in a Day course will get you started with PowerApps at no cost! Click the link below to register for your FREE course today!

New call-to-action
bg-img14.jpg

Join Our Blog

Join thousands of other SQL Server, BI and cloud pros by subscribing to our blog.

Leave a comment

Posts by Topic

see all

Recent Articles

Popular Articles