Showing posts with label Components. Show all posts
Showing posts with label Components. Show all posts

Friday 28 February 2020

I love Power Apps

No self respecting technologies/programmer/ex-programmer likes simple solutions.  I still chose C# as my go to problem solver (I learnt to use a hammer 18 years ago and now all my problem look like a nail).  Don't tell anyone under 30 I still love C#, they think you are weird if you don't use Javascript for everything.  And 15 years ago I was arguing the same with the C++ golden oldies.  So the circle of life goes on.  Enter Simba, the Lion King...  Well not really but Power Apps is just making programmers look ridiculous.

Power Apps can do a lot...

MS have announce that components and PCF’s are part of Power Apps.  I've been using this for awhile and it's awesome.

This diagram outlines extending Power Apps using Components:  Developers often say you can’t extend Power Apps so it is not a real language, my answer is really… 
The other argument for PowerApps is if you need to do any complex programming.....  Use an Azure Function (this allows C#, PowerShell, JS, …).  Simple to build in your own language, expose using an http endpoint and you can call the end point using a custom connector.  
So if you need: 
  • Complex UI = go PCF, 
  • Reusable UI e.g. menu's = use Components, 
  • Complex processing or secure code logic = Azure Functions.
Here are some PCF examples that we can use that are already built:

So what is stopping Power Apps:
  1. Licencing - the licencing is expensive so you need to choose selectively when it is appropriate.  If MS change it's going to just go crazy the usage. IMHO. 
  2. Functionality:  MS have introduced automated testing to the Power Apps platform but there are improvements scheduled.  For me the biggest issue is code reuse.  I wish there was a function library that you could write functions to and call in a single line of code, my individual field logic can be insane and tough to amend on complex large Power App UI's.   
Excellent blog on Power Apps

Tuesday 18 February 2020

Power Apps Component bug fixed


Problem:  Creating a new component with Input parameters.  When using the component and setting the custom input parameter with a global variable, the value passes thru, as the variable is reset, the control does not update with the variable.  Replication Steps are recorded  in the 2 min 20 sec recording showing the issue.


Initial Hypothesis: I have a large Power App project that uses this technique a lot.  The global variable were working until Fri 14 Feb 2020.  I believe the Power Apps version has been updated and is causing the issue.  I have tried the work on multiple environments and tenants.  It is happening across them all.

https://powerusers.microsoft.com/t5/Building-Power-Apps/Power-App-Components-not-working-with-Global-variables-used-with/m-p/473414

Warning: This affects Power Apps release 3.200221.27 (rolled out to me on Fri 14 Feb 2020), I think 3.20014.23 (latest release as of 13 Feb 2020) was still working correctly.  Don't change your app if it published on the lower versions until Microsoft release a new version.  This only affects Power Apps using Components and using Global variables on the component's input parameters.

Resolution: Power Apps release 3.20022.17 as of 20 Feb 2020 (UK tenant) has been fixed.  Quickly identified and corrected.

Sunday 19 January 2020

Power Apps Quick Tips

Some of my Power Apps notes:

Licencing:
Determine your Power Apps licence using Power Apps Web user interface:
Power Apps > Settings > Plans

Note:  Microsoft changed how Power Apps licencing works circa Nov 2019.  The Power Apps licence with O365 E3/E5 does not have the connectors so is useful only for simple apps, and using flow, the apps can get more advanced.

Testing:
I saw a preview of the Power Apps Test Framework as the Microsoft Ignite Tour in mid Jan 2020.  The framework allows for recording UI tests and inserting asserts.  The tests are stored alongside the project inside Power Apps.  PowerApps Testing is in beta, it will be release by region so presumably it's already available in some US regions on the public beta.  The CI/CD pipeline integration was not shown but I'm sure some smart fella will look at this shortly.  I'd use Selenium for automated web testing at this stage, but that may change especially for mobile app development.

Updated 28 Jan 2020: Test Studio for Power Apps released today.  Here is the announcement.  Here is another recording outlining testing of Power Apps.

In the Power App > File > Settings > Advanced Settings > Scroll down to "Formula-level Error Management" and turn on the feature.
Open the "Advanced tools"
Accessing Test Studio in Power Apps


Power Apps Development Standards:
Error Handling - Should an unexpected event occur, log so the issue can be traced, as of 3 Feb 2020, PowerApps has App Insight integration.
Naming standards - Label visual controls and variables
Approved Colours - Digital branding standards
Reuse - Control reuse with shared branding
Roles - AAD connector allows me to figure out the user group the current user belongs too so they get appropriate menus, screens, and actions.
Menus -  @Laura-GB https://www.youtube.com/watch?v=5G-gVWRItmc  Build a menu component, input allows one to combine with AAD roles to create dynamic menus for users.
Copy and pasting OOB controls - such as a textbox, if you use a formula, the values are persist and passed around.  So if you have a color set by a variable, copy and paste results in the new text box referencing the colour.  Taking this further, if you put in the position X and Y a formula e.g. X=66*1 and Y=100*1, the control will inherit the parent controls property rather than reset the property.

Steps to setup and Use a Custom Connector:

Get the http response from a custom connector and add to a collection
Common Functions:
DateTimeValue() - Convert string into a date
Text() - Format a string
Value()- Format a string into a numeric
Text(DateTimeValue(TextInput1.Text), "dd-mmm-yyyy")
An approach I like to advanced Power App Input Validation.
Lookup() - Finds the first record in a table, closely related to Filter() and Search()
I.e. Fx> Set(Lookup(<DataverseTblName>,<UniqueRowId>=GUID("1234-1234-111...") 
Patch() - Update or add new, best way to save as it handle collections
Patch() function used to update an existing "Appeal" record.  Also note that a json string is saved- This is how to escape quotes.

Error Handling and Logging:
PowerApps has pretty basic error handling IfError(Try, if fail fall back)
Error Handling for Power Apps
The is a built in mechanism to log from Power Apps into App Insights.

Components:
Build a common UI element such as a menu or header.  The component has input and output parameters so you need to pass in the data to be used and return the output.  This allow the component to be re-used.  Obviously it makes sense that you can't use global variable within components, you need to pass the global variables in using input parameters.
Great example from @Laura-GB https://www.youtube.com/watch?v=5G-gVWRItmc