Despairing at data not linking across tables

I’ve got so confused with linking tables. I thought I had it sussed but I don’t. Can anyone help me. I’m trying to create a page where I have inputs that any logged in user can use to add orders to my app (later on I’ll look at payments etc) which will track who’s bought what products when and from where. I have data types for orders, products and venues which are the only ones I’m interested in now.
My “Orders” Data Type has a field for ProductName (of type Products) to show what’s being bought - that should be linked to my Products Data Type . There’s then a field for ProductPrice which I’d like to pull the price through from the Products Data Type but which doesn’t seem to work. My next field for Orders is for VenueName (of type “Venue”) to show where it was bought from that should link to my Venues Data Type. The remaining order fields are for Date, Time and an order number which will be pertinent to each order.
It’s when I come to workflows that I run into trouble. I’ve attached them to an “Add New Order” button at the bottom of the page. The workflow is to Create a Thing > Type = Orders. Any field that links across to a different datatype just doesn’t work. I get issues telling me they’re “Should be products but now they’re texts” which I don’t find very helpful.

I’m starting to despair at what I’ve missed here so if anyone can shove me in the right direction I’d be so grateful.

This is the app…it’s only a test one so there are a few extraneous data types that are hangovers from other experiments.

For now I have to jump on a zoom and then I’ll be away until tomorrow but I do appreciate any input in the meantime.

Your inputs are simply taking a text value that the user types into the input.

That value doesn’t relate in any way to anything in your database (i.e. a product) - it’s simply a text value (a string).

You’re trying to add a ‘Product’ to your ‘Order’ so the value needs to be a ‘Product’ (an existing entry from your database). Right now the value you’re trying to add is simply a text - so it won’t work, and hence why you’re getting the error ‘value should be a product but right now it’s a text’.

In order to add a product to your order you need to specify an actual ‘Product’ to add.

Assuming you don’t want to give your users a way to select an existing product directly (i.e from a dropdown, or list etc.), then you’ll need to find the relevant ‘Product’ from the database, and then add that to the order in the product field.

So, in your case, you need to find the product who’s name matches the value of the ‘name’ input.

So in your workflow, when you are adding the Product to the Order, you need to do a search for product’s who’s name matches the text value from the input, and then select the first item. That will add the actual product to the order.

I’ve gone ahead and added the correct expression to your workflow in your editor (below the 2 that are giving you errors) so you can see how it needs to be done.

Bear in mind, when using a text input to find an item from the database, you’ll have to take into consideration capitalization (searches are case sensitive), and also that any typo or miss-spelling will not return a result, so will result in no product being added to the order. For this reason it might be an idea not to rely on a text input for adding a database entry to another datatype’s field. Or you could add a step to verify that a product does exist matching the input’s name, and give an error message to your user if not.

Thank you SO much! Genuinely. I really appreciate you taking the time out to look into this and for explaining it clearly and calmly to me AND putting the correct expression in there for me. This is really going to help. “You’re a gentleman and a scholar”, thank you!

1 Like