Get location data or ip

I’m trying to build a Timeclock app. Is there anyway to get location data from the user or log the ip?

1 Like

oh damn! CurrentLocation() works! Saw it from this guy: Set a color in conditional format by formula

1 Like

It works in safari on a Mac. Works in the iOS app. But breaks in the safari iOS… not sure why.

Hey @Keizo_Gates, welcome to the community!

It’s a hidden formula though (undocumented and unsupported) so don’t rely on it in production or assume it may stop working at any moment. I don’t think even Codans remember it was there.

Fair enough, it’s not super critical, but it’s nice to have the data. Is there anyway to skip a functions use if it fails? Something like Try Except in python.

You can keep the CurrentLocation() formula separate as a named formula or a separate column. Even if the function gets deleted and the formula becomes broken, other formulas dependent on this one will still calculate, simply treating this one as blank:

You can then have a fallback value and rely on this formula throughout the rest of the doc:

Thanks, tried that. It does seem to still crash the doc if location is not allowed. Can’t seem to find a way around that. Would be awesome to just leave it blank if it fails.

Oh, I see now. I never blocked location :slight_smile:

It doesn’t crash the doc, but it seems to block any further calculations unless location is allowed and the doc is reloaded. I don’t think there’s any remedy to that.

You can defer the location function with _Delay(CurrentLocation()), and this will let some other calculations to complete before this one is scheduled (_Delay() is pretty much Javascript’s SetTimeout() and puts this function on the next event loop cycle), and use this chance to display a message to the user to enable location if the doc is stuck for them.

Maybe that’s what you see on Safari on iOS btw; location is disabled by default and calculations in the doc are blocked.

1 Like

On iOS, it currently says “CURRENTLOCATION not supported in this execution context”. This breaks my workflow :cry:. Hopefully they enable location use on mobile soon!