User Interface Management
Locking down SharePoint so only Integrated App can be used
This is an issue that has been the subject of many questions and below is the series of processes which I believe adequately addresses the structure needed.
Firstly, the three initial things to do (which I will not go into any depth with) are: –
- Configuring any SharePoint Views to display only the columns the users need to see.
- Filtering the View data so that it displays only the records required to be available for choosing. I am assuming here that the users need to see records other than those they created.
- Configuring the Integrated App to restrict the users (or the particular user) to only be able to do and see what they need.
However, there are a number of inbuilt SharePoint functions that allow a reasonably knowledgeable user to circumvent these controls and do/see things they should not be able to do.
Dynamically filtered multi-select check boxes
Firstly, my thanks for the inspiration for this to Reza Dorrani in his great video. Please refer to it if necessary for the checkbox gallery insertion process. I am now taking this a couple of stages further with: –
- Dynamic selection of the Checkbox content filtered off a (single select) Radio control.
- Store the radio value in a Text field and the Checkboxes content in a Multi-Choice field.
- Show and modify existing records including a change in the Radio Control content.
- Continue to do all of this with SubmitForm() rather than any Patching.
Prevent the use of Special Characters in a Text input
This process prevents a user from saving a range of Special Characters if entered in a Text Input. This may have other application as well as the Text Box example. A working example is sh
So how does this work?
Search and autofill in text box based on List values
We are all used to web searches giving suggestions of possible values you want and Combo Boxes have a Search function, but Text inputs do not have anything built-in for this, so it should be useful to have this function as well.
In the example below, the user starts typing and all matching values come up below. At any time they can press Enter and have the first (or only) matching value populate automatically in the Text Box.
Restricting users to specified file types in Attachment control
This is a fairly straight-forward, but useful function to restrict users uploading attachments to file type specified. The example below restricts to JPG or PNG, but could be anything you choose. As soon as a non-allowed file is uploaded, it is immediately deleted and a message displayed regarding allowed file types. This code needs to go at OnAddFile in the Attachment control.
Using Office 365 Groups for Security/Control inside Power Apps
Office 365Groups have many uses, particularly when Security Enabled, for controlling user authorities to access individual Power Apps while also allowing the same group to control access to the data source (“all in one place”).
However, you can also use the user’s membership of any group (not necessarily having access to the app and not needing security enablement) to control what they can do and see once the app is opened. This blog discusses the options for enabling the functionality.
Changing the Authoring Version of an App
There are times unfortunately that Power Apps releases a new Authoring Version in the Design Studio that does not always perform as expected. Any app last saved in this new version may be affected by whatever the deficiency is and an updated version of an app with minor changes may suddenly develop unwanted characteristics. The easiest way to see if it is the version that is causing these issues is to re-publish the app on an earlier version, the best being the last one (before the most recent) it was saved in and was working properly.
This is quite a straight-forward process, but can be a little confusing if you do not know how it works.
Enter Time directly instead of drop-downs
Have you ever wanted to throw away the drop-downs that Power Apps supplies for time fields and simply have the user enter a valid time. For this you would also want to display the time currently stored in the data source and do both in an hh:mm format.
It is not as difficult or complex as you may think and can also all be done within a SubmitForm() action using the Update property of the data card. Here are the steps required.
Detecting mobile device app operation
There is a generally simple method of detecting a mobile device where
Location.Altitude > 0 || Acceleration.X > 0
being true will detect a mobile device (as opposed to a PC), but we now have “cross-over” devices with these sensors being used as office PCs – so how do we detect them? What we really need to know is if the app is being run in a browser or on the Mobile App.
Many to Many Filters
This article discusses the example of a multi-choice field in SharePoint with a multi-choice Combo Box in Power Apps filtering the possibility of ANY selected field in the Combo Box matching ANY stored value in the list which is stored in a Complex (Table) field.
Many on Many queries can be done directly in a Filter, but are not Delegable. To do this, firstly a Table needs to be created using ForAll addressing each of the Combo Box selected items to see if any are contained in the multi-select Choice field
Shift numbered items in a gallery by more than one row
There are many posts on reordering a gallery with up/down buttons, but what if you want to shift an item a large number of places and re-order everything in between in one action ? The assumption here is that the gallery contains a sequential numeric field, is sorted by this field and the user wants to change a row item to another position with the result that the gallery will then be sorted in the new order.
Firstly, there are two possibilities on the number shift – it could be larger or smaller than its original position, so that needs to be dealt with separately. I have also allowed for there being no other unique identifier (such as the ID) in the record, so will use the number field only.
Duplicating a Canvas App Form into SharePoint Integration
You have just finished your Canvas app and now you would like users to also have the facility directly from the SharePoint list. You already have the form in the Canvas App set out the way you want, and now need to duplicate this on SharePoint
This is a perceived barrier that really is not one. A lot of people envisage having to maintain two apps or go for the integration option and have to manage the limitations this brings. Any form created in a stand-alone app (SA) can be directly copied and pasted into a SharePoint Integration (SPI) screen doing the following: –
When you do not have to say true or false
This is a misunderstood subject to some degree and once you grasp it, you will save a lot of unneeded code. Boolean (true/false) values can only have two possible outcomes. We are accustomed to Boolean fields (although they are best avoided for other reasons) , but all If() statements can only have one of two results (they are true or not).
Some control properties are also Boolean results – for example Visible. When you want to set the Visible property of a control conditionally, you might say something like on a button
If(
CheckBox.Value = true,
true,
false
)
Combining two collections based on order alone
There are times that you have two sets of data that you want to turn into one and they are actually “matching” in order, but have no common field. The number of fields in each does not matter, however you need to pick one (generally the one with the most fields), then add the fields from the other one. The example below only has one field in the first and two in the second, but show the principle of adding consecutive numbers to each and then joining them.
This uses two collections – the collection process is only an example for testing and producing the resulting data sets to demonstrate the code needed to combine them.
Finding the newest versions of a criteria in a data set
Have you ever wanted to find the newest/latest of all the different categories in a data set? For instance, the latest sale by each sales person, the last registration by a person – and generate a list of these.
Firstly, a disclaimer here as the function used is not Delegable, however if all records you are looking for are in the newest 2,000 records, then read on. I am also assuming SharePoint as a data source in the example below. Firstly, the code required
Displaying Days, Hours and Minutes between two Date/Time values
Have you ever wanted to see exactly how many hours, minutes and seconds are between two selected date/time values. The formula below assumes that the user has selected from two Date Pickers with the Hour and Minute value from drop-down controls (as are provided by a standard Power Apps Date and Time field controls).
Displaying and saving time in 12 hour AM/PM format
When Power Apps sets up a Date/Time field, the hours are in 24 hour format. Have you ever wanted to work with a 12 hour AM/PM choice and display for the user ? Here is how