How to do a repeat insert query from a repeat input form?

Hi All,

I’ve given this a red hot crack! (aussie slang) but can’t get iot working or find docs on the matter.

I followed along with help from this post:

What i’m trying to do is this:

  • Have an input form in app connect that has repeat for a few fields (to allow the user to quickly add multiple items in the DB)

  • The number of repeats would be linked to a variable/counter that would increase when the user presses a ‘add’ button (this step i can get working)

  • The form then adds multiple rows of data into the DB based on how many rows the user inputs.

Here is how i have set up the server action:

Here’s the Insert query:

And here is the form in app connect, including setting up a dynamic name using the index of the repeat:

Lastly, when i run the insert action in Chrome, i get a server error 500 with the following message:

The input parameters appear to be being parsed correctly…but i’m not sure exactly they should look like as I’ve never done a multi-insert before:

image

Sorry for the detailed post, but hoping someone can help point me in the right direction… i’ll go work on something else till then so as to not bang my head against the wall :slight_smile:

Cheers!

This may help

1 Like

Thanks Ben, i’ll look into it. I always forget to check DMX… never used it personally so forget where Wappler came from.

2 Likes

I just use name attributes with brackets to represent an array. Remove the dmx names and just use firstname etc. for the field name.

Firstname[]

But does that account for the multiple POST inputs?

i.e. firstname1, firstname2 etc.?

Sure. Although they are not numbered, but it sounds like you don’t need that. Every new input can have the same name and then it will be an array for your server side repeat.

Sorry, I glossed over that you want pairs of inputs. On the server side you can repeat one input (eg firstname) and then use $index to gets its mate ( eg lastname) within the same repeat.

Ok… So i pretty much just followed the steps that @ben linked and it worked first time.

I used the Multi insert server action step and the form generator on app connect side…worked fine!

I think maybe what was missing in my last set up was that i did not name the repeat the same as the server array (i.e. record).

Anyway, the generator worked really well so no complaints here.

2 Likes

I’m trying to do this and might have started in reverse order, as I have my form submitting the values but can’t figure out how to set up the server action.

This is the values the form is submitting:

I’ve added my array and the variables that are being posted:
image

And have the repeat defined as the OrderDetails array:
image

But when I go to select them in the in the Insert Options, I can’t find the variables for the columns:
image

How do I select the column from the repeat?

I figured it out.
Turns out you have to just assume the field values in the array and type them in manually where needed. It would be nice if Wappler would add the feature to be able to pick them, though.

I just save the Server Connect and then click on the server connect refresh button to make the variables appear, you shouldn’t need to type them in

Hi, I’m trying to do the same, but I can’t. Can you please show us how you did it.?
Thanks