cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
antholee
Frequent Visitor

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

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
CarlosFigueira
Power Apps
Power Apps

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

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.

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!

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

May UG Leader Call Carousel 768x460.png

June User Group Leader Call

Join us on June 28 for our monthly User Group leader call!

PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

Top Solution Authors
Users online (1,997)