Search bar not linking correctly

Hi all,

I’ve been following the Power-up: Search bar with suggestions tutorial, but I can’t get it to link to the correct pages within the app – all of the displayed search options just link to one single product page. Any help on this would be greatly appreciated.

Here’s a summary of what I’ve done so far

  1. Created an app variable “antimicobials” with the product information

  2. On Ampicillin product page, created a page parameter “antimicrobial_id”

  3. On the search page, created page variable “search_text”

  4. On the search page, placed an input field and set the value equal to the page variable “search_text”

  5. On the search page, placed a container with a text field inside of it and repeated it with the formula

SLICE(SELECT(appVars.antimicrobials,CONTAINS(LOWERCASE(item.name),LOWERCASE(pageVars.search_text))),0,4

Then, bound the value of the paragraph to the product name. (I’m wondering if there’s an issue here since mine states “incompatible” and “object with two properties is not assignable to type text / number”

  1. Bound container visibility from #5 to the following formula
    !IS_EMPTY(pageVars.search_text)

  2. Added open page logic for the search box, chose the “Ampicillin” page as the target. When I set the product_id to current_id – I get the same incompatible text (the type “objective with 2 properties” is not assignable to the type “text”)

  3. The video doesn’t go into detail but at 0:43 they talk about setting the page variable on the product page. On the Ampicillin page, I created a page variable “selected_product”

In the logic section, I put in a set page variable function and set the variable name to “selected_product” and assigned the value as the following formula

FIND(appVars.antimicrobials,params.antimicrobial_id==item.id)

It shows the error – Object type is not assignable to text type

When I try to use the search bar, it is hidden until I start to type, it brings up the names defined in my app variable list but all selections link to the Ampicillin product page.

Does anyone know how I can get the pages to link appropriately?

Thanks!

Yes, it shows incompatible, but only for the object. Not for its properties.
In the step 5 just click on the “name” and You are good to go.
In step 7 click on the “id” and it should work.

And for the steps after 7 I would go with a
selected_product that has the same schema as the one on the search page… So object with 2 properties (id, name). [Not a list, just a single object].
And set the page variable flow function to the FIND function You used. That should work. [The error that you have there is that You have a “text” page variable, but in the appvars list you have objects with 2 properties.

But do You have a data resource?

I mean it is app variable that can also contain a bunch of data, but I guess using data resources would be a better practice in general.

Thanks for the insight! I did what you mentioned – selected “name” in step 5 and “id” in step 7.

I also changed the selected_product page variable to an object with two properties (id, name)

Changing the selected_product to an object corrected the error as you mentioned.

Unfortunately, I’m still have the same issue. On the search page, it’s only opening the page that I specifically linked the open page logic to. Not the selected search result.

I don’t currently have a data resource but can set one up if that would make the search function work.

Thanks!

Oh, now I see… There is no way to dynamically set the specific page. Or in fact I did read a workaround, but that involves custom javascript etc…
for Your case the setup would be a templated product details page, where you set the name, image, price, description etc… to a data record or for the sake of it an app variable.
Because if you now set any text on the Ampicilin IV page to the selected_product.name, it will show that.