This post covers using Loqate API to auto-fill address details in PowerApps. Manual entry of key customer and supplier details is error prone and time consuming.
The Loqate API is really simple, so you can develop a solution in a couple of minutes.
Watch the video for a demonstration of how I was able to develop a Power App that enables address search:
Address Lookup in PowerApps with Loqate
The app in the video uses two flows to get address information from Loqate.
The first flow uses the Interactive Find API method to get a list of possible address matches. Each result contains a unique ID which is used to drive the second flow.
The second flow uses the Retrieve API to get the details of the selected address from the first result set.
First Flow: Interactive Find
The flow is quite self explanatory. There are two inputs
- The country code.
- The search query.
These variables are inserted into the the query string and submitted to loqate using a HTTP action.
The interactive find returns a JSON array, which looks like this:
[ { "Id": "GB|RM|A|53530442", "Type": "Address", "Text": "Microsoft, 2 Kingdom Street", "Highlight": "0-9;0-6", "Description": "London, W2 6BD" }, { "Id": "GB|RM|A|55068353", "Type": "Address", "Text": "Microsoft Reactor, 70 Wilson Street", "Highlight": ";0-6", "Description": "London, EC2A 2DB" } ]
The Id column, which is highlighted above provides the input for the next flow.
The addresses are loaded into a collection which is used as the data source for the gallery of addresses:
ClearCollect(Addresses, TestAddressLookup.Run(txtAddressLookup.Text, dropCountry.Selected.Value))
Second Flow: loqate reteive
The second flow uses the Unique ID retrieved in the first flow to get all the details of the selected address:
Like the first flow, the results are stored in a collection, with the following code:
ClearCollect(AddressDetails, loqateRetrieve.Run(ThisItem.Id)); UpdateContext({searchVisible: false})
I used a context variable called “searchVisible” to set the visibility of the address lookup controls.
Back in the actual form I just set the default property of the dataCardValue text controls to:
First(AddressDetails).Company
First(AddressDetails).Line1
First(AddressDetails).Line2
etc
Download the flows to import into your environment here:
Flow 1 – Loqate Interactive Find
Flow 2 – Loqate Retieve
And that is how easy it is to add Address Lookup functionality in PowerApps! Any questions, just ask.
Mezza says
Really useful! Great work 🙂
Allan says
This looks great, however for some reason when I run the 1st flow I am only receiving a true value to my collection despite the body output json looking as though it is containing all the correct data. do you know why that would be?
Paulie says
I’m not sure why that would be happening, did you make the flow from scratch or import the one I put on the blog?
My output JSON looks like this on the final step:
[
{
"Id": "GB|RM|B|412",
"Type": "Address",
"Text": "Nando's, 7 The Academy Belmont Street",
"Highlight": "0-6",
"Description": "Aberdeen, AB10 1LB"
}
]
Is that how yours looks?
Allan says
My flow output looks like that however when I collect it I only get Value:True.
Obviously something that I have done as I created from scratch. I ill try importing the .zip.
Paulie says
Let me know how you get on (and post solution if you find it!)
Iain Ray says
Hi Allen, did you get this sorted, it usually happens if you have ran the flow out side the ClearCollect. To fix you have to remove the PowerAutomate Flow from the app under the Action Tab for what ever you have assossiated with and then remove the associated data source.
Then add the PowerAutomate Flow again to your button or what ever triggers it, make sure it wrapped with ClearCollect before you run it for the first time or it will happen again.
Great Blog Paul, i built a simliar solution using getAddress.io for one of my apps a few months ago, yesterday i see there is now a built in Address input component using TomTom data.
https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/geospatial-component-input-address
Ive messed arounf with it but still feel my Postcode lookup works better but i will see how what my form users think.
Thanks
Paulie says
Hi Iain, that is interesting! I didn’t know that was available and does not seem to require a 3rd party to achieve. I actually changed my method to use a custom connector instead of a flow, a bit easier to work with at the PowerApps end.
Bob Smith says
Hi Paulie
Really loved this video as I have known this could be done but never had the time to work through all the steps.
Firstly I could download the first workflow but it does not import, The second works a treat.
I do though have a problem in that the JSON response for me coming back from the API and subsequently adding to a collection creates a collection with a Table and not the list of records. I can click on the table inside the collection and see the responses OK, but I cannot figure out how I can show this inside a Gallery.
I Emailed Loqate and they said that the API returns a container as below when a Postcode is added (See Below).
Have you any hints on how I surface a collection containing a table in a Gallery ?
Id GB|RM|ENG|8QT-GU14
Type Postcode
Text GU14 8QT
Highlight 0-4,5-8
Description Riverside Close, Farnborough – 45 Addresses
Paulie says
Glad you enjoyed it. I’ve actually thought about re-doing this video as I think it would be better (simpler) as a connector rather than a flow. Also PowerApps now has built in support for address lookups, have you check it out?
Address Input component for PowerApps
Bob Smith says
Hi Paulie
Heavy week end but ended up with this solution for extraction of a returned table in collection :
Clear(Addresses);
Collect(
Addresses,
Active_Find.Run(
txt_AddressQuery.Text,
txt_Country.SelectedText.Value
)
);
ClearCollect(
AddressedUngrouped,
Ungroup(
Addresses,
“Items”
)
)
The Ungroup creates a new collection that flattens the table.
Great video on this as if you look for another solution on the WEB you will struggle to find one, and Addresses in SP are Bread and Butter processes.
I spotted this new Power Apps feature. So perhaps not only an Address map a Map as well. Things just keep getting better.
Thanks
Bob
Ridah says
Hello this is a great video but I cannot get the flows to even upload. keep getting an error. Is there something I am missing? are these still good? went to the loqate site and cannot find these flows! did you do an updated video using the new geospatial feature. any help appreciated