Thursday, December 22, 2016

Microsoft PowerApps and Flow - TIPS

I will update this post as time goes on.

TIP #1 - Limit the data surfaced to the current user.

NOTE: Context Variables are scoped to a single screen, if you need the variable to be scoped to your entire application, use a Collection Variable instead.

How?
Use the Filter Function and a Context Variable, you can even use the text value of a Textbox instead of a Context Variable if you want.

1. Set a Context variable to be created when the Home or First Screen of your app is made visible, then set the value of this Context variable to User().FullName, User = Current Logged in User. 

ex. In the Advanced tab of your screen properties set the OnVisible property to 
UpdateContext({CurrentUser: User().FullName})

In my humble opinion: The OnVisible property would also be a good place to refresh your datasource connection so that you are seeing the latest and greatest, you can have multiple functions set in this property, just make sure you put a ; at the end of each function, except the last function.

ex: UpdateContext({CurrentUser: User().FullName}) ; Refresh(DataConnection)

2. In your forms Properties section, under the Advanced tab, set Items to 
Filter(SharePointList, Initiator = CurrentUser)

At the time of this post, PowerApps does not support SharePoint Person or Group fields, therefore I manually created and set an Initiator field in my SharePoint List.
You can change the Initiator by triggering a Workflow every time a new row is inserted into your list but for now I set the field manually.

Now your Form or Gallery control will only show the records that the current user submitted. 
Alternate ex. Use the alternate for the Created By Person field, Filter(SharePointList, Author.DisplayName = CurrentUser)

Please Note: This throws the following informational message but seems to still work in my case.

TIP #2 - PowerApps Web Studio

The Web Studio is only available for Microsoft Edge, Chrome or IE11 at this time.


TIP #3 - Reset a dropdown control to it's default by changing it's Reset property with a Context Variable.

A Context Variable is scoped to the current screen.

1. Set the OnVisible property of the screen to UpdateContext({resetDropdown: true})


2. Set the Reset property of the dropdown control to the value of the context variable, resetDropdown

3. Add another button to update the Context value to a different value so that it can be reset when you navigate back to the screen below. UpdateContext({resetDropdown: false})

TIP #4 - Reset a dropdown control to it's default by changing it's Reset property with a Collection Variable.

A Collection Variable is globally scoped to the current app.



1. Set the OnVisible property of the calling screen to ClearCollect(ResetDropDown,First(ResetDropDown).Value = false)





2. Set the Action OnSelect property of the calling button to ClearCollect(ResetDropDown,First(ResetDropDown).Value = true)





3. Set the Dropdown Controls' Reset property of the calling button to First(ResetDropDown).Value






4. Set the Back Button OnSelect property to ClearCollect(ResetDropDown,First(ResetDropDown).Value = false)




Initially setting the controls' Reset property to true does not trigger a Reset of the control. The Reset of the control must be triggered by updating it's Reset property.


TIP #5 - Use a Toggle Control to Filter your Gallery



Hope this is helpful!

- Keith


Microsoft PowerApps and Flow Learning Resources

An ongoing list of Microsoft PowerApps and Flow Resources I'll update as I come across helpful resources. Main Sites: https://p...