Power Fx Named Formulas for the Win!
Rob D'Oria
Inventor & engineer focused on automation, artificial intelligence, and accessibility.
I received a few questions on the video we posted earlier today on re-creating InfoPath Rules and Calculated Fields in Power Apps.
Check it out here: https://youtu.be/KJyraLKCQPs?si=XEak4gh1xjorDr5q
We started looking at Named Formulas late in 2022 and while it was clear almost immediately that we could use them to help re-create InfoPath Rules and Calculated Fields it was an experimental feature until very recently...and as a general rule of thumb we don't release new capabilities in Kudzu until they are in wide preview.
While there's some good information online regarding Named Formulas, there's none that we could find that discuss using them to replicate the types of rules and calculated fields you might find in an InfoPath form. And a lot of the content would lead you to believe that changes to values referenced in a formula won't cause the formula to update...which simply isn't true.
In one of the examples from the aforementioned video we had an InfoPath rule that would change the BackgroundColor to Orange and ForegroundColor to White if the DesiredBonus field was greater than 10,000.
In Power Apps, you end up with two formulas, one for the background color and a second for the foreground color:
领英推荐
With those defined you simple set the Color and Fill properties to the previously defined formulas:
And it's important to note that as values referenced in the formula are updated, the formula recalculates and immediately updates any properties that reference it. It's not after you navigate away from the field, it's as soon as there is a change...again, this is obvious in the video we posted earlier today.
This same approach can be used to handle show/hide, enable/disable, and other InfoPath rule types. It can obviously also be used to replicate calculated fields.
Again, we know the content out there says it doesn't update, portrays any formulas you create as effectively being constants, and largely focuses on this being a replacement for weighing down App.OnStart. Thankfully it's so much more and a rather straightforward (and importantly, maintainable) way to replicate InfoPath Rules and Calculated fields. The alternatives we pursued were all ugly and effectively created Power Apps that would be difficult to maintain.
Oh, and if you're still trying to figure out how to convert your InfoPath forms (and their data) we can most likely help. Check this out and give us a shout: