How to add data to linked data types via a page

I have three Data Types:
Products = List of my products
Outlets = List of places to sell those products
ProductsAtOutlets = What Products are sold for how much etc at those Oulets.

I want a page where the logged in user adds Products available at their outlets…I can do this on the Data tab by directly entering them as a new record into App Data but I’m getting nowhere with it on the Page I’m creating.
My Page Type of Content = ProductsAtOutlets
I have a workflow to Add a new thing to Products at Outlets but the fields for Venue name and Product names (which are linked to the Data Types Venues and Products) don’t accept any inputs from my page and the issue is something like they’re supposed to be “Type ProductsAtVenues” but they’re Text.
Can anyone help me? I’m pretty sure this is meant to be simple but I feel spectacularly stupid with it at the moment.
All the best

1 Like

From what you’ve described, I’m assuming that you’re allowing your user to enter a ‘text’ input for the ‘Product’ and ‘Venue’, rather than selecting an actual product or venue from the database.

So they’re just entering a ‘text’ value rather than selecting a database entry - hence the error message ‘this should be a product but right now it’s a text’ - the value needs to be an actual product, not just the name of a product.

If you want to create a new ProductAtOutlet entry by allowing users to type a text input to set the Product and Venue fields, then you’ll need to search your database to find a product and venue that match the input text values.

So to set the ‘Product’ field, do a search for Products who’s name matches the text product input value, then select the first item from the returned list of products.

Note that searches are case sensitive, so if a user types in all lowercase but your Product Name field has a capital letter at the start, it wont match - so you’ll need to build in some logic to account for that, or make sure you store all product names in lowercase.

Also, of course, any typos or misspellings the user types will result in no match from the database, so will end up with an empty field for ‘Product’.

Personally, I’d recommend against this method of matching database items to text input values, as there’s a lot of scope for errors (such as typos, misspellings, and capitalization issues) resulting in empty field values on the new database entries.

Perhaps a more reliable way to approach this is, rather than allowing users to type into a text input and then match what they’ve typed to a database entry, is to force them to select products from the actual database - either from a dropdown or RG, which can be filtered by a text input (or any other criteria), or by using a search box (which will show a list of products updated in real time matching what’s being typed). That way you will ALWAYS have a match and won’t end up with empty Product fields when creating a new ProductAtOutlet - plus it’s a better UX for the user.

On a side note, from what you’ve described, there’s no reason to set a content type on the page for this, unless the page will also be used for editing or displaying single existing ProductAtOutlet entries.

1 Like

You’re correct and I understand your solution. Thank you. Your knowledge is hugely enviable!

This now leads me to another question (sorry!)

From my users’ perspectives, they’ll be looking at a list of their own individual Outlets (displayed in a RG) and will click a button at the end of a row in that RG that will display another PopUp displaying that row’s Outlet’s products. That works fine.

At the bottom of that PopUp, there’s an “Add Products” button that loads another Pop Up in which they can enter new products and their details just for that Outlet. IMO, it would be a better User experience if they don’t have to enter the name of the Outlet again as they’ve already selected it in the RG. I do need to record it in the db though because Outlet name is an essential part of each record of “Products at Outlets”.

So my question is…
What’s the best way for me to achieve having an automatic value of the “Outlets Name from the Outlet that was originally selected on the RG’s” appear in an input for them so they don’t have to enter it again? I’ve been trying but can’t get beyond Red expressions and blank inputs.

I really do appreciate your help and your tenacity having read this far!

Simple…

Make sure both popups have a content type of ‘Outlet’.

Presumably, when the User clicks the button on the Original RG (the one displaying the User’s Outlets) your passing that ‘Outlet’ to the Outlet Popup using a Display Data workflow action.

So, all you need to do to pass that Outlet to the next popup is use the same action (Display Data) when the ‘Add Products’ button is clicked, and pass the Outlet Popup’s Outlet (or Parent Group’s Outlet - depending on what other groups you have inside the popup) to the next popup (the Add Products Popup).

Then from within that popup, when the final workflow runs to add the products, you can just refer to the Parent Group’s outlet to set the Outlet field on the ProductAtOutlet entry.

1 Like

Adam,
Again, I’m indebted to you. Thank you so much! It works!! You presumed correctly, I was using a Display Data workflow but I wasn’t “chaining” them together like you said. I have now and it works. I think I had started on the right lines but then inexperience took me down other rabbit holes and got me lost. You’ve really helped me and I’ve learned a lot.
I wish I was as accomplished at something as you are with Bubble so I could help you in return one day!
Have a lovely rest of day.
All the best
Joe

1 Like