Empty Lat/Long Conditional With If....Else But Not Working


I’ve got old entries in the database that are missing lat/long information and a button on the page that is supposed to trigger google maps directions on the users phone.

I conditioned it to look to see if the string is empty and show a toast if so, but for some reason, it doesn’t do that , and it crashes the app instead…

Do apps crash if it looks for something that isn’t there?

What is wrong with the below setup?


I was facing the same issue, are you using Bubble as your backend? If so are you using the geographic address field to store lat/lng? If you are then you can apply the if else statement to the address field of Bubbles geographic address object.


I am using stored lat/long values in seperate form (a number) not a complete geographic address element.


Do you have any particular reason not to use the geographic field? I was using number fields too until I realized it’s much cleaner to use the geographic field insted of having two separate number fields. Geographic field also opens up mor functionality in Bubble itself.

Only option you have at the moment is to go into Bubble and setup a Workflow to run on a list which will go change all the null values to 0 for your lat lng fields.

The app is crashing because it’s comparing a 0 integer to a null value


That’s correct @umer.snap… and I think you were onto it there in your original question @justincrabbe

If something is null it’s the absence of data and when checking for “empty”, it’s going to crash as there’s nothing to technically grab a hold of to check for empty.

I’m not certain about the geographic fields and Bubble but @umer.snap sounds like he’s got some good experience with them if you decide to make the adjustment.


So I can call the geo-address created inside bubble in Dropsource and somehow create the same map directions without first creating a lat/long object? @umer.snap @wade

I thought i had to create a lat/long from 2 numbers first and then open map for directions.


I’m not sure I’m following exactly on this. I’m not super familiar with Bubbles geo data you 2 are referring. @umer.snap might know it sounds like.


Is there a way to test against the geo address saved by bubble to determine if it’s empty somehow @wade ?

Possibly by counting the characters in the response such as if…else… the Field contains less than 5 characters (assuming ‘null’ with 4 may be passing through if empty) that the if… else… statement fires?


I would really like to understand how you’ve set this up in a way that calls the Bubble Geo-Addy @umer.snap, thanks!


Hi @justincrabbe

The logic would depend on how the data is structured when it comes back with null outcomes. Use the network log (or even better, Postman) to see what’s sent back in the JSON when null for these values is being sent back. See if the field is simply not included in the callback payload or if it is included with “null” being sent in the field as a string. Once you know if a string is being sent back or not when this occurs, you can determine what logic statement is necessary to validate. If a null string is not being sent back, maybe on Bubble’s side you can send it that way and then you could test to see if the string is equal to “null” or as you suggested a character count logical statement could work too.


When I use the network log in the app online previewer, it doesn’t show me anything actually, it only crashes the app but doesn’t update the log.


I solved this by creating a default setting for the field and then testing against the default.

Seems like you need something to be inside the field/database when the call is made by dropsource so that the if…else fires…


Interesting catch there. I’m not completely certain but that does seem plausible actually.