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:
Set(ResetGallery,true);Set(ResetGallery,false)
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.
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.
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.
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.
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.
Set(showSpinner,true);Patch();ForAll();...All the actions...;Set(showSpinner,false)
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!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.