Assembling data from different app elements to write to the DB

I'm building a relatively simple (ha ha) app to explore retool. This webapp is a participant-registration form for a sport. I'm attempting to link the data from two forms into a single "submit" button action.

My container has two elements: 1) A selectable list "Session" listbox showing the sessions available, and 2) the "Participant Information" form.

My problem is how do I merge these two sets of data into something I'm able to write out to the database? I can write registrant data, I can access the selected "session" PK (seen here as "2"), but I can't seem to combine them to write out to the table:

(just saw I had the form set to trigger on change - disregard!)
I suspect this has to do with the "AdditionalScope" feature, but the use-cases I'm reading up on are waaay too intense for me to parse out. This tight video came close, but it's only reading data from other elements, not showing how to assemble the data for writing out.

I've spent more than a few hours experimenting with this - please point me in the right direction?

I'd recommend using 'GUI Mode' here. In the changeset field select 'Object' and use the form data, plus a field for the session_list_id.

GUI mode will definitely make things easier to spot in this case, for 90% of cases you probably won't need to write an insert command

The error message is suggesting that it's a mismatched datatype (ie that's usually numeric and character data mixups) but it also looks like you're hand-crafting the substitution vars into your insert statement? You shouldn't need to do that with Retool as it'll protect you from SQL injection by default. Also worth noting is the two little arrows on the green SQL Prepared Statement box, that'll show you the statement as a string so you can see what values it was trying to insert - another good way to spot what's not working as expected.

1 Like

I'm more comfortable writing SQL queries than trying to figure out the GUI mode, so yes, I was trying to handcraft the substitution vars. Thanks for the tips - my SQL is stronger than my JS!

1 Like

Ah... there we go.
I had to lookup the '...' (append data) and ':' (declare shortcut) operators as my JS is not strong. This works, and is exactly what I needed to get me on the way. Thank you.