Multi insert troubles

I have a multi insert which does something strange in server connect. On the front end I have my form with the usual naming for a multi insert i.e.

name="record[{{$index}}][memberHolidayFund]"

And it displays the array in server connect:

I set up an repeat and set value action just to test the repeat as the values weren’t inserted in the database

When running the action there are 2 empty items in the array before any of my expected items appear:

Screenshot 2022-12-07 at 05.32.36

I get the following error:

“status”: “500”,
“code”: “ER_WRONG_VALUE_COUNT_ON_ROW”,
“message”: “insert into transactions (memberHolidayFund) values (‘R130.40’, ‘R59.40’) - ER_WRONG_VALUE_COUNT_ON_ROW: Column count doesn’t match value count at row 1”,
“stack”: "Error: ER_WRONG_VALUE_COUNT_ON_ROW: Column count doesn’t match value count at row 1\n at Query.Sequence._packetToError

Does not seem like I am doing anything wrong since I have used the multi insert many times recently.

this is the data for my repeat step. Not sure if it is the problamatic part:

"repeat": [ { "Id": 2, "memberNo": 1234, "surname": "Koos", "initials": "K", "names": "Koos", "employerid": 1, "category": "F", "queryMemberHolidayFund": { "itemid": 6, "amount": 130.4, "active": 1 }, "queryMemberBonus": { "itemid": 7, "amount": 130.4, "active": 1 }, "queryMemberProvidentFund": { "itemid": 8, "amount": 432, "active": 1 }, "queryMemberCouncilLevy": { "itemid": 9, "amount": 0.2, "active": 1 }, "queryMemberTradeUnion": { "itemid": 10, "amount": 5, "active": 1 }, "queryMemberTotal": { "itemid": 11, "amount": 698, "active": 1 }, "queryContributionCouncilLevy": { "itemid": 12, "amount": 2.2, "active": 1 }, "queryContributionWageGuarantee": { "itemid": 13, "amount": 0.45, "active": 1 }, "queryContributionFuneralBenefit": { "itemid": 14, "amount": 0.49, "active": 1 }, "queryContributionTotal": { "itemid": 15, "amount": 701.14, "active": 1 }, "weeks": 4, "calcTotal": 2804.56 }, { "Id": 1, "memberNo": 123, "surname": "Schmidt", "initials": "M", "names": "Marcel", "employerid": 1, "category": "A", "queryMemberHolidayFund": { "itemid": 6, "amount": 59.4, "active": 1 }, "queryMemberBonus": { "itemid": 7, "amount": 59.4, "active": 1 }, "queryMemberProvidentFund": { "itemid": 8, "amount": 192, "active": 1 }, "queryMemberCouncilLevy": { "itemid": 9, "amount": 0.2, "active": 1 }, "queryMemberTradeUnion": { "itemid": 10, "amount": 0, "active": 1 }, "queryMemberTotal": { "itemid": 11, "amount": 311, "active": 1 }, "queryContributionCouncilLevy": { "itemid": 12, "amount": 2.2, "active": 0 }, "queryContributionWageGuarantee": { "itemid": 13, "amount": 0.45, "active": 0 }, "queryContributionFuneralBenefit": { "itemid": 14, "amount": 0.49, "active": 0 }, "queryContributionTotal": { "itemid": 15, "amount": 314.14, "active": 0 }, "weeks": 4, "calcTotal": 1256.56 } ],

Are you sure your front-end is sending the data correctly? I don’t think your problem is in the server action

The cause for the first 2 empty items is because memberHolidayFund is undefined (non-existent) for those items, so Set Value doesn’t actually set anything

Thanks @Apple. I realised the front end is the problem and I am reverse engineering the generate form with multi inserts so I can incorporate a not so basic query as values for the fields.

Slowly but surely getting there by adding 1 field at a time. I have learned with Wappler you must start with the basics(provided by the app’s point and click section and then work your way to the more complex stuff.

Mistake I commonly make is to start with my version and then I overlook basics that the app already does for you.