Javascript working in-app but not in database

Hi. I am trying to create a system where a random location will be chosen, but so long as it meets a set criteria. Each “Job” will have a “Generator”. Each “Generator” will have “geographic address”. Each “Job” will also have a “Location”.

I want to determine the location based on these criteria:

  • It is within a 5 mile radius of the “Generator’s geographic address”
  • It is not on water

How can I achieve this?


bump - this feature is really important to my app


Run this JS code using toolbox plugin-

when you return the address, just call the google api to verify the address is on land or in water.

Ankur@ Nocodetalks
Looking for a Bubble Coach? Check out here

Thank you :slight_smile: How can I actually get the value returned from the JS?


Use this feature of toolbox.

Where can I find those options? My Run Javascript action only has these options.

When you drag the “javascript to bubble” element, all these options are available there.

I see. Thank you. I wonder though, how can I make this work as expected. I want to generate one location. I will need to use the Run Javascript action with the script you provided, then I presume get the data from the Element via a bubble action.

How can I make the Javascript link to the element on the page? Do I need to edit the script?

Hi. I got it working, kind of. I am having an issue now trying to use a custom latitude and longitude. I have added this code to the usage example at the bottom. As you can see I am using a custom lat and long. In debugger, the lat and long is prefilled correctly. However, when I then check the corresponding page element - it has no value. Why is this? Also, when I click the button to run again, I get a “temporary error”.

// Usage Example. // Generates 100 points that is in a 1km radius from the given lat and lng point. var randomGeoPoints = generateRandomPoints({'lat':Result of step 1 (Create a new Oust...)'s genBuild's Loc's latitude:rounded to 2, 'lng':Result of step 1 (Create a new Oust...)'s genBuild's Loc's longitude:rounded to 2}, 1000, 1); bubble_fn_a(randomGeoPoints);

In an attempt to get some final help on this, here is where I currently sit.

  1. When the user presses to generate a new call everything works in app preview, when viewing in step-by-step debug mode all the data lines up.

  2. However, in the database, the field I specifically created for latitude and longitude is set to 0,0 (despite in the app preview, the linked field being filled)

  3. The location (geographic address) field is also not filled, despite the latitude and longitude in the app being filled.

  4. If I want to try and generate a new call, I get an error explaining that “We ran into a temporary error, please try again.”

I have decided to share the editor link, to view:

You can see a video of this happening here:

I am desperate to fix this and I am currently days behind schedule because of this confusing error.

When trying to log the Javascript elements list’s count into the database it prints as 0. What am I doing wrong?1 :weary:

This topic was automatically closed after 70 days. New replies are no longer allowed.