Address Validation Example

Address Validation Example

Power Automate is not just a great tool to enhance business logic (like the famous Approval workflows used by so many organizations). It can also add great functionality to PowerApps applications. In this article, I want to provide an example.

I recently worked on a project that required that users can get entered mailing addresses validated. Online shops often use this functionality to ensure, the entered address is correct - prior to accepting an online order. This article is about how to implement this functionality by using a PowerApps application and a Power Automate flow.

The user interface of the PowerApps application wasn't too complicated. The following screenshot provides an example:

No alt text provided for this image

The user types in an address into the textbox on top. Once the user clicks on Validate Address, the PowerApp application calls a Power Automate flow, which does all the heavy lifting.

As mentioned, the flow is called once the user clicks on Validate Address. Because the flow is called from within PowerApps, the parameter (the address to be validated) needs to be requested from PowerApps and stored in a variable.

No alt text provided for this image

Next, the validation API is called. We decided to use the web service offered by PostGrid, but Canada Post and others are offering similar services too. Calling the web service isn't hard if you follow the guidelines of the provider. In my example, the call looks like this:

No alt text provided for this image

I blurred the API key in the above image. Most (if not all) services require to use of an API key which you'll get once you subscribed to the service. If you check the Body section in the above screenshot, you'll notice two things:

  • I used the HTTP action, which unfortunately is a premium action
  • I applied a filter because I am only interested in Canadian addresses

As the response is JSON, I used the Parse JSON action in Power Automate to extract the validated address from the response. The Parse JSON action takes its input from the previous HTTP action. To configure this action, just take the output of the previous action (basically the JSON response) from a successful run and use this to generate the schema.

No alt text provided for this image

The validated address (or addresses) are copied to an array first, which is converted to a string prior to returning the addresses back to the PowerApps application.

The application takes the response from the flow and lists the validated addresses as items in a Listbox. The user can pick one of the validated addresses or continue with the address entered manually. Well - on theory :-) Unfortunately, there is a limitation in Power Automate as it can only return scalar data types, but it can't return an array of addresses.

No alt text provided for this image

This is unfortunate, as it requires some thinking on how to overcome this limitation. My current approach is to create a JSON object with validated addresses, convert it into a string, return it to PowerApps and try to extract the validated addresses. This will definitely require some coding - even in a low-code environment. At the moment, I am fine with returning just a single address, but once I figured out how to return multiple addresses, I will create a follow-up post to this one.

Anyways - I think this example illustrates how citizen developers can take advantage of PowerApps and Power Automate to create solutions, which previously required custom development and a skilled C# developer. Without hardly any coding (except for the few lines in the HTTP action's body element, which could be copied from the provider's documentation (and the tricky return of multiple addresses), I was able to create a solution, that users can utilize to validate mailing addresses.

Update: As mentioned, I was working on a workaround to return multiple addresses. First, I created a web service, that my Power Automate flow calls instead of directly calling the public web service. This allows me to better handle the response from the public web service. My custom web service takes the response from the public web service and creates a long string containing all the addresses. The format I used looked like this: {FullAddress: 1234 Wall Street, Halifax, Nova Scotia, E4W 6D2, Canada}. As it is unlikely, that addresses contain this character (|), O used it to separate multiple addresses. Here is what that looks like: {...}|{...}|{...}

The next problem I needed to solve was how to extract all the addresses from that big string. PowerApps offers the Split() function and it can be used like this:

No alt text provided for this image


This call creates a collection (addresses) that contains separated address strings. The following image shows the collection:

No alt text provided for this image

Not bad, but the address strings need a little bit more formatting before they can be added to a Listbox. True, I could have used my custom web service to do that kind of formatting, but I was curious, about how to do that in PowerApps. Here is my solution to this:

No alt text provided for this image

I assigned the collection "addresses" to the items property of my Listbox hoping the address strings would show up. They did :-)

No alt text provided for this image

Lesson learned: there are ways to work around some limitations of Power Platform, although they sometimes require some thinking outside of the box. My solution might not be the most sophisticated one, but it works for me and -that's important- I learned something new regaring handling collections in PowerApps!

To view or add a comment, sign in

More articles by Oliver Wirkus

  • Power Platform Integration

    Introduction When discussing Power Platform Governance and Compliance, it is important to not just focus on Power…

    1 Comment
  • Power Platform Tools

    Introduction Although the Power Platform admin center provides some useful tools, many administrators are looking for…

  • Power Platform Processes

    Introduction If Governance concerns managing platforms like Power Platform, there is indeed a strong need for…

    1 Comment
  • Power Platform Monitoring

    Introduction In my previous article, I talked about why governance is important in running a power platform as a…

  • Power Platform Governance

    Introduction Power Platform has evolved into a professional development environment for organizations. The times of…

    1 Comment
  • Enhancing the SharePoint Online user experience with customized PowerApps forms

    SharePoint Online Forms Experience SharePoint Online has been an integral part of Microsoft 365 since the beginning…

  • Power Platform - Manage Licenses

    If you are dealing with Power Platform for a long time, you probably will agree that managing licenses can soon become,…

    1 Comment
  • Power Automate - Hidden Trigger Properties

    The ability to trigger a Power Automate Flow from within a PowerApps application provides many benefits. Especially the…

    1 Comment
  • A simple integration approach

    I admit this might not be a sophisticated solution nor is it meant to be an article for tech-savvy Power Platform…

  • Why Branding?

    If I think about "Branding", the first thing that comes to my mind is the branding of a corporate website. I may have…

    2 Comments

Explore content categories