Showing results for 
Search instead for 
Did you mean: 

10 PowerApps hacks/ troubleshoots/ workarounds that might help you in building Canvas Apps

In this article I will highlight 10 interesting PowerApps hacks/ workarounds/ troubleshoots that might help you in building canvas apps. This article is inspired by a couple of questions that I have been repetitively seeing on the community forums. Being documented at one place, it could be a good cheat sheet for all level of users (beginners/ mid/ pros) while building apps.

Let’s get started!

Regex based text inputs: There might be scenarios where input text fields are being used on data forms. Currently by default the only formats on a text input control in Canvas Apps are text and number. To over come this, we can match the entered input with the regex set on the "OnChange" property of the text input control. Example: A form where a text input is placed to record the email address from a user. The regex is a part of the expression set on the "OnChange" property of the text input control that will check if the input text matches that of an email address and if not, clears the text field and shows the hint text to "enter a valid email address".  


Expressions on the text input control:

OnChange Property: If(!IsMatch(TextInput1.Text,"^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$"),Set(ResetText,false);Set(ResetText,true),Set(ResetText,false))

HintText: Hint Text: If(ResetText,"Enter Valid Email")

Reset: ResetText

Reset/ refresh gallery control: Currently there is a limitation on resetting all the individual controls/ elements within a gallery control from an external control (control outside of the gallery; e.g., button) in canvas apps. A workaround for this is to reset the individual controls in the gallery based on a variable whose value can be changed by a button. All the controls in the gallery have their reset property set to this common variable and the value of this variable is controlled using the button. 


Expression used on the "Reset Gallery" button: 


The reset property of all the individual controls in the gallery is set to "ResetGallery" (variable). 

Custom Tooltip: To guide the users who will use the app, a custom tool tip can be created that will display the suggestions on how to use that particular control on the app. For example, if there is a text input that expects a certain type of an input from the user (e.g., password) then this custom tool tip is displayed to the user until they are typing something in the text input box. The tooltip will disappear when the user clicks out of the text input control. CustomToolTip.gif

The custom tool tip here is a text label and the visibility of this is in sync with the "OnSelect" and "OnChange" properties of the text input control. 

PDF Viewer: Currently PowerApps does not support uploading of PDF documents and storing them as files on the app. The PDF viewer control can only be used to view files that are remotely stored (basically something that generates a URL for the document). A workaround for this is to save the PDF file as an image file on the local machine and upload it as media. Then use this image on the "Document" property of the PDF Viewer Control. MicrosoftTeams-image (60).png

Blank Values: There might be scenarios where you might want to remove the values of fields/attributes in any entity/list and save a blank value for that particular item/ record and by default this is not enabled in PowerApps. To do so, you need to enable the "Formula Level Error Management" setting in the app settings. Once this is enabled, it allows the users to remove the existing values and save null values.

Note: This is not applicable on *required fields/attributes.
App Settings -> Advanced Settings -> Formula-level error management -> Enable it.MicrosoftTeams-image (61).png

JSON response from a Custom Connector: When a custom connector is created it is required that you provide an appropriate JSON format in its "Actions". If not, though a JSON is expected as a response while using this connector in the canvas app, when the action is triggered, even if the request is completed successfully, it will just return a true/false (boolean) value. To resolve this, and get the JSON response in a collection on the canvas app, you need to define the response JSON payload by creating a default/ sample response. Once that is defined and added to the custom connector, the connection to the custom connector needs to be removed and added again so that the appropriate response is returned. Here in the sample, the response JSON data needs to be passed and the schema will be generated.MicrosoftTeams-image (62).png

Attachments/ Files/ Binary Data: In a scenario where the requirement is to move attachments/ files/ data from PowerApps to SharePoint document library, data can be passed through variables (two variables, name and content). This is suitable for one attachment and with a few string manipulations, the file can be saved successfully. But in a case of multiple files (where the number is not certain), this might be a hectic task to pass them all with a separator and then removing the separators to get individual values. A better way to do this is using the JSON function through which you can convert the collection into a string format, where all the attachment data is stored and just by parsing one string into JSON, all the attachments can be created. This also has the option of including the binary data, which doesn't require and further string/ data manipulation on the flow. More on JSON function to move data from PowerApps to document libraries via Flow: here.

Data flow in nested galleries: While using a gallery control within a another gallery, you might want to access the value from the parent gallery to one of the child galleries. This cannot be done directly as the individual items in the parent gallery are out of scope of the nested child gallery. For example, consider a gallery where the data is grouped by Products. The main gallery contains the product name and the grouped data (let's say customer data), then the nested gallery inside the main gallery has the grouped table as items. If you want to perform any action based on product name inside the main gallery, the product name cannot be retrieved directly in the nested gallery. To address such an issue, you can create a label inside the main gallery, assign the item you want to access in its text property and set the visible property to false. Now, you can use this control name in the sub gallery to use the value in any further actions.
Loading Screen: Consider a scenario where you want to suppress user intervention while the data is loading (huge data sets) or a Flow is being executed and a response is expected, you can create a custom loading spinner and set its visibility based on the control action that is getting executing.
1) Create a rectangle and set its color to light grey or any other color of your choice, usually this is somewhat transparent for the background, you can use the RGBA code as: RGBA(0-255,0-255,0-255,0.5)
2) Upload a loading spinner gif as a media file. Place an image icon at the centre of the screen and refer it to uploaded media.
3) Now, set the visibility of both the above created control to a variable named, showSpinner
4) To toggle between the Boolean values, you can update the long time taking action's expression as:
Set(showSpinner,true);Patch();ForAll();...All the actions...;Set(showSpinner,false)
Almost anything using Custom Components: In case you are seeing any limitations with any of the controls, you can try creating custom re-usable components. You can combine multiple controls to behave like one and there can be custom input/output properties. The main advantage of this is the re-usability and the capability to extend/ enhance any already existing controls. Although there are many sources where you can start with for learning how to design your own custom components, here is a blog that I published where I have demonstrated a custom re-usable component for an alphabet based slider control.  

In this article I have shown you 10 hacks/ troubleshoots/ workarounds with the most commonly faced issues in building canvas apps. There are many such interesting scenarios and those have been posted as solutions on the community forum here. It is highly recommended to run through these while facing any issues or before creating a new thread as a solution to an issue you are facing might already have been provided and all one has to do is look in the right place.

I hope you found this interesting and it helped you. Thank you for reading!