
ben Wakefield-Harrey
Power Automate Get Long and Lats From SharePoint Location Field

So we all know how frustrating Location Fields are in SharePoint they are just so interesting especially as they return Long and Lats for a location.
But in Flow we cannot do anything with the information. Try to find it we find nothing.
See Raza's great article on this https://rezadorrani.com/index.php/2018/12/04/location-columns-for-sharepoint-online-lists-libraries/
After I saw this amazing article by Paul
https://www.tachytelic.net/2021/07/power-automate-sum-sharepoint-column/
I thought this looks interesting can I get a flow to actually get the Long Lat information using using RenderListDataAsStream and then reading more it got even better can put a filter on it! FilterField1=ID&FilerValue1=
Step 1 Created a simple List I with a Location Field
Title
Place in the Sun {LocationField]

Ticked all the fields Coordinates is the one I am after
Add two more number fields
Long
Lat
So now we are presented with a simple list like this

Step 2 Flow Time
Create a flow to be triggered on

Nothing complex
Next

Changing the path to your site/name
Collecting the guid viewid from the allitems url
Now the clever bit

Extend this from article and add in the filterfield1=ID&FilterValue1= ID from the trigger
Here is the full peek of the code
"parameters/uri": "_api/web/lists/GetByTitle('@{outputs('Settings')['listName']}')/RenderListDataAsStream?View=@{outputs('Settings')['viewID']}&FilterField1=ID&FilerValue1=@{triggerOutputs()?['body/ID']}",
When I tested this it worked! i got all the values back from the item including the Address and Coordinates!
So now add in two compose statements to extra this information

outputs('Send_Request')?['body']['Row'][0]['Placeinthesun']['Coordinates']['Latitude']
outputs('Send_Request')?['body']['Row'][0]['Placeinthesun']['Coordinates']['Longitude']
Last bit is re write the information back to the lists

So now we have Coordinates we can use! My mind thinks could get a map to appear in a SP List and take these Coordinates all in Json formated view!
I will try later
