Forum Academy Marketplace Showcase Pricing Features

Passing field data from one page to another based on search/match of accompanying field's data

Working on a simple voucher code system. Have it set up on the forum app at https://bubble.io/page?type=page&name=voucher&id=forum_app&tab=tabs-1

Type: Voucher

Field: Firm Name
Field: Voucher Code

After typing in a valid Voucher Code and clicking the Claim Voucher button, I’d like the page to redirect to the voucher_confirmation page which will display the Firm Name associated with the valid Voucher Code that was typed in.

The search a valid Voucher Code part is already working thanks to @NigelG , but I can’t get the accompanying Firm Name to display on the voucher_confirmation page.

I have the following two sample entires in the forum app database…

Firm Name: ABC Corp
Voucher Code: ABC123

Firm Name: XYZ Corp
Voucher Code: XYZ789

My best guess is that I need to do something with the “Data to send” section of the “Go to” action on the Claim Voucher button, but I’m not sure what flow to build out there. The several things I’ve tried have not worked.

As per the other thread, there are a few ways of passing data around …

  1. Normally you are passing a thing around, so setting a content type on a page (works well for lists of things)
  2. You can store something on the database (often the User)
  3. Page parameters was added fairly recently

In this case you can easily pass a THING to the page so option 1) , because you want to pass a specific voucher.

So on the click you re-search for the voucher on the database (a pain I know !) and then pass this in the “data to send”.

You need to set the receiving page up to want a voucher.

OK, the important bit here is the use of “:first item” on the click’s search.

Bubble only let’s you send a single thing to a page. But a search, even if it returns a single thing, thinks that is a list. A list of one = a list in bubble land. So we have to tell it to only fetch a single thing back. And that is “:first item”.

You could do this with a parameter, and send the voucher code, then do the search and display the firm name. But this seemed safer as it is passing a voucher about.

2 Likes

Thanks again @NigelG.

I went with your option 2; “you can store something on the database (often the User)” because there is also User data getting called onto that voucher_confirmation page. My assumption is that I wouldn’t have been able to set the page’s “type of content” to Voucher if I wanted to also call User data.

So I created a “make a change to the current” action and followed your “first item” example along those same lines. Worked like a charm. :slightly_smiling:

1 Like