cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
antholee
Level: Powered On

Error with UpdateContext and Location.Latitude/Longitude when used in button

Hello,

 

I am using a button to pull GPS coordinates that will populate 2 fields. the following in the OnSelect property errors out:

 

If(CBLLat=Blank(), UpdateContext({CBLLat:Location.Latitude}); UpdateContext({CBLLong:Location.Longitude}), UpdateContext({CBLLat:Blank()}); UpdateContext({CBLLong:Blank()}))

 
 

This also errors out for the location: Round(Acos(Sin(Radians(Location.Latitude)

 

The first error is an invalid argument type where CBLLat=BLank(), and the latter two are "Invalid use of '.'" in each Location function.These same formulas work in other screens on the same app. Does anyone know why this may be occurring, especially when in other screens these errors do not occur?

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Power Apps Staff CarlosFigueira
Power Apps Staff

Re: Error with UpdateContext and Location.Latitude/Longitude when used in button

You may see this error if you have a column called 'Location' in the data source that is associated with the Form - within the form when you type 'Location' it will refer to the column of the object, not to the global Location signal. If this is the case, try using the disambiguation operator to 

If(
    CBLLat = Blank(),
    UpdateContext({ CBLLat:[@Location].Latitude, CBLLong:[@Location].Longitude }),
    UpdateContext({ CBLLat:Blank(), CBLLong:Blank() }))

Hope this helps!

View solution in original post

3 REPLIES 3
Power Apps Staff CarlosFigueira
Power Apps Staff

Re: Error with UpdateContext and Location.Latitude/Longitude when used in button

Are the context variables CBLLat and CBLLong defined elsewhere (you can check on the View -> Variables option in the ribbon)? I tried defining the same expression that you used, and didn't see any errors.

ForumPost000.png

antholee
Level: Powered On

Re: Error with UpdateContext and Location.Latitude/Longitude when used in button

Hi there, 

 

No, the context variables are not defined elsewhere. I have tried with different variable names and it resulted in the same issue. One thing to note is that this error occurs within the Data Card, but works fine outside. In addition, these same Location.Longitude and Location.Latitude work in other Screens of the same app, but now not in any new ones I've been adding.

Power Apps Staff CarlosFigueira
Power Apps Staff

Re: Error with UpdateContext and Location.Latitude/Longitude when used in button

You may see this error if you have a column called 'Location' in the data source that is associated with the Form - within the form when you type 'Location' it will refer to the column of the object, not to the global Location signal. If this is the case, try using the disambiguation operator to 

If(
    CBLLat = Blank(),
    UpdateContext({ CBLLat:[@Location].Latitude, CBLLong:[@Location].Longitude }),
    UpdateContext({ CBLLat:Blank(), CBLLong:Blank() }))

Hope this helps!

View solution in original post

Helpful resources

Announcements
New Ranks and Rank Icons in April

'New Ranks and Rank Icons in April

Read the announcement for more information!

Better Together’ Contest Finalists Announced!

'Better Together’ Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

thirdimage

Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Join THE global Microsoft Power Platform event series

Attend for two days of expert-led learning and innovation on topics like AI and Analytics, powered by Dynamic Communities

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

thirdimage

Community Summit North America

Innovate, Collaborate, Grow - The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Top Kudoed Authors
Users online (10,855)