Setting Maximum Value in slider using 'Search For...'

I’m attempting to populate the Maximum Value in a slider using a value stored in my app’s database. First, some context on how my app is organized:

  • I’m populating things in the database using a form on my ‘index’ page.
  • I’m using the unique id from that newly created row and passing it as a URL parameter via email in a workflow.
  • On a separate page in the app, I’m looking up that row in my database using unique id as the constraint and matching it against the unique id from the URL

  • Finally, I’m trying to pull a value from that row into my Maximum Value for a slider on the new page. For some reason, it isn’t satisfied with just the value it is getting back.

Any thoughts on what I’m missing here? Thanks in advance.

The max value field is looking for a single number. The “Search for” option returns a list, so bubble sees it as more than a single number (even if the search returns only one number). Try adding “first item” to the max value.

2 Likes

Agreed with @nnich19. One more suggestion: if you’re looking for the highest commission_max number in that Search, you can also do “Search for Offers’ commission_max :max”

This will give you the single value that it requires but also retrieve the highest commission_max value out of all the commission_max values that come back in that search. I only suggest this because you may not have any other way of constraining the search to do that and “:first item” may not necessarily be the highest number.

2 Likes

Thanks @nnich19. I tried adding ‘first item’, but it now wants me to add additional statements:

Your note about “Search for” being for lists, I wonder if I’m going about this all wrong. The user will only have access to the single “Offer” associated with the unique id I’m passing via URL parameter. Each “Offer” only has a single “Max Commission”, so all I’m trying to do it return the “Max Commission” number for that offer and use it to set the Max Value in the slider. Is there a better way to do this that doesn’t involve “Search for”?

Thanks @romanmg. I tried this approach but did not see the “:max” statement in the dropdown menu:

Scrolling down further, it still doesn’t appear. I’m sure I’m overlooking something obvious. Any other ideas? See my note in response to @nnich19 above for more info.

Is the commission_max field a text or a number?

Even with :first item, it would still be compatible if it was a number, but from your screenshots, it seems like you have field set up to something other than number which is what you need here.

1 Like

Ah, that is definitely the issue. It was incorrectly set up as a text field, when it should have been a number. Sorry I overlooked that!

I updated the statement to include “:max”, but the slider does not move when the page loads:

I created an input on the page to confirm the Max Commission value was coming across, and it populated as expected. Does it have something to do with how the slider loads vs when it access the data to populate the Max Value? Just guessing at this point. Thanks so much for your help.

The link on the last post was broken. Here’s a better one:

https://partner-calculator-input.bubbleapps.io/version-test/partner_calculator?oid=1522118646107x831136628033978400

Again, the Max Commission field populates as expected. Thanks.

Cool, so we’re getting closer. If you want the slider to default to that max value on page load, right-click the expression, copy, and paste it into the initial content field (where it’s currently set to 0)

1 Like

Success!! Thank you so much. I’m new to the platform, but quickly becoming a believer.

1 Like

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