Issue with Multi-Record Insert in Wappler

Hello Wappler Community,

I am currently facing an issue with the multi-record insert functionality in Wappler and would greatly appreciate your assistance in resolving it.

Problem: When attempting to use the multi-record insert, I encounter a limitation where only a reduced number of records are successfully added beyond a certain threshold. Surprisingly, regardless of the field values used, the issue becomes apparent when trying to insert more than approximately 15 records.

What I Have Done:

  1. Verified the database structure: I have checked the table structure in my database (MySQL) and ensured that there are no constraints or limitations causing the issue.
  2. Checked data consistency: I have confirmed that the data being bound to the hidden input fields is correct for each iteration. The data type and format of the values are consistent with the corresponding database column types.
  3. Reviewed server-side error handling: I have implemented error logging using the error_log() function to capture any specific error messages, but no relevant errors are being logged.
  4. Explored database limitations: I have tested different combinations of fields and observed that the multi-record insert works well for a low number of records (e.g., 15 or fewer).

Code Sample: Below is the code snippet for the repeat section in my Wappler project:

                <div class="modal-body" id="modalExportCSVTicketsBody">

                    <div class="bs-callout bs-callout-primary bs-callout-xl">

                        <p>

                            <span dmx-show="(scAppSettings.data.qrUserLanguage.user_language == 'en')">

                                Form fields marked with the (<span class="text-danger fw-bolder">*</span>) are required.

                            </span>

                            <span dmx-show="(scAppSettings.data.qrUserLanguage.user_language == 'fr')">

                                Les champs de formulaire marqués d'un (<span class="text-danger fw-bolder">*</span>) sont obligatoires.

                            </span>

                        </p>

                    </div>

                    <p>

                        <span dmx-show="(scAppSettings.data.qrUserLanguage.user_language == 'en')">

                            Total number of tickets to export {{scProjects.data.qrTicketsAll.total}}.

                            <span dmx-show="(var_ticket_status.value || var_ticket_type.value || var_ticket_complexity.value || var_ticket_severity.value || var_ticket_actual_result_mark.value)">

                                withthe following filters:

                            </span>

                        </span>

                        <span dmx-show="(scAppSettings.data.qrUserLanguage.user_language == 'fr')">

                            Nombre total de tickets à exporter {{scProjects.data.qrTicketsAll.total}}.

                            <span dmx-show="(var_ticket_status.value || var_ticket_type.value || var_ticket_complexity.value || var_ticket_severity.value || var_ticket_actual_result_mark.value)">

                                avec les filtres suivants:

                            </span>

                        </span>

                    </p>

                    <p dmx-show="(var_ticket_status.value || var_ticket_type.value || var_ticket_complexity.value || var_ticket_severity.value || var_ticket_actual_result_mark.value)">

                        <span class="badge rounded-pill me-2 ps-4 bg-secondary" dmx-show="var_ticket_status.value">

                            {{var_ticket_status.value}}

                            <input id="ticket_statusvalueAddExportCSV" name="ticket_status" dmx-bind:value="var_ticket_status.value" type="hidden">

                            <button class="btn text-white btn-sm" dmx-on:click="!var_ticket_status.setValue()">

                                <i class="fas fa-times" aria-hidden="true"></i>

                                <span dmx-show="(scAppSettings.data.qrUserLanguage.user_language == 'en')">

                                    <span class="sr-only">

                                        Remove {{var_ticket_status.value}} status filter

                                    </span>

                                </span>

                                <span dmx-show="(scAppSettings.data.qrUserLanguage.user_language == 'fr')">

                                    <span class="sr-only">

                                        Supprimer le filtre de statut {{var_ticket_status.value}}

                                    </span>

                                </span>

                            </button>

                        </span>

                        <span class="badge rounded-pill me-2 ps-4 bg-secondary" dmx-show="var_ticket_type.value">

                            {{var_ticket_type.value}}

                            <input id="ticket_typeAddExportCSV" name="ticket_type" dmx-bind:value="var_ticket_type.value" type="hidden">

                            <button class="btn text-white btn-sm" dmx-on:click="!var_ticket_type.setValue()">

                                <i class="fas fa-times" aria-hidden="true"></i>

                                <span dmx-show="(scAppSettings.data.qrUserLanguage.user_language == 'en')">

                                    <span class="sr-only">

                                        Remove {{var_ticket_type.value}} status filter

                                    </span>

                                </span>

                                <span dmx-show="(scAppSettings.data.qrUserLanguage.user_language == 'fr')">

                                    <span class="sr-only">

                                        Supprimer le filtre de statut {{var_ticket_type.value}}

                                    </span>

                                </span>

                            </button>

                        </span>

                        <span class="badge rounded-pill me-2 ps-4 bg-secondary" dmx-show="var_ticket_complexity.value">

                            {{var_ticket_complexity.value}}

                            <input id="ticket_complexitAddExportCSV" name="ticket_complexity" dmx-bind:value="var_ticket_complexity.value" type="hidden">

                            <button class="btn text-white btn-sm" dmx-on:click="!var_ticket_complexity.setValue()">

                                <i class="fas fa-times" aria-hidden="true"></i>

                                <span dmx-show="(scAppSettings.data.qrUserLanguage.user_language == 'en')">

                                    <span class="sr-only">

                                        Remove {{var_ticket_complexity.value}} status filter

                                    </span>

                                </span>

                                <span dmx-show="(scAppSettings.data.qrUserLanguage.user_language == 'fr')">

                                    <span class="sr-only">

                                        Supprimer le filtre de statut {{var_ticket_complexity.value}}

                                    </span>

                                </span>

                            </button>

                        </span>

                        <span class="badge rounded-pill me-2 ps-4 bg-secondary" dmx-show="var_ticket_severity.value">

                            {{var_ticket_severity.value}}

                            <input id="var_ticket_severityAddExportCSV" name="ticket_severity" dmx-bind:value="var_ticket_severity.value" type="hidden">

                            <button class="btn text-white btn-sm" dmx-on:click="!var_ticket_severity.setValue()">

                                <i class="fas fa-times" aria-hidden="true"></i>

                                <span dmx-show="(scAppSettings.data.qrUserLanguage.user_language == 'en')">

                                    <span class="sr-only">

                                        Remove {{var_ticket_severity.value}} status filter

                                    </span>

                                </span>

                                <span dmx-show="(scAppSettings.data.qrUserLanguage.user_language == 'fr')">

                                    <span class="sr-only">

                                        Supprimer le filtre de statut {{var_ticket_severity.value}}

                                    </span>

                                </span>

                            </button>

                        </span>

                        <span class="badge me-2 ps-4 bg-secondary rounded-pill" dmx-show="var_ticket_actual_result_mark.value">

                            {{var_ticket_actual_result_mark.value}}

                            <input id="ticket_actual_result_markAddExportCSV" name="ticket_actual_result_mark" dmx-bind:value="var_ticket_actual_result_mark.value" type="hidden">

                            <button class="btn text-white btn-sm" dmx-on:click="!var_ticket_actual_result_mark.setValue()">

                                <i class="fas fa-times" aria-hidden="true"></i>

                                <span dmx-show="(scAppSettings.data.qrUserLanguage.user_language == 'en')">

                                    <span class="sr-only">

                                        Remove {{var_ticket_actual_result_mark.value}} status filter

                                    </span>

                                </span>

                                <span dmx-show="(scAppSettings.data.qrUserLanguage.user_language == 'fr')">

                                    <span class="sr-only">

                                        Supprimer le filtre de statut {{var_ticket_actual_result_mark.value}}

                                    </span>

                                </span>

                            </button>

                        </span>

                    </p>

                    <div class="form-group mb-3">

                        <label class="form-control-label fw-bolder" for="prexport_nameAdd">

                            <span dmx-show="(scAppSettings.data.qrUserLanguage.user_language == 'en')">

                                CSV export name:

                            </span>

                            <span dmx-show="(scAppSettings.data.qrUserLanguage.user_language == 'fr')">

                                Nom d'exportation CSV:

                            </span>

                            <span class="text-danger" aria-hidden="true">*</span>

                        </label>

                        <div class="input-group input-group-merge">

                            <input type="text" class="form-control form-control-prepend" id="prexport_nameAdd" name="prexport_name" required="" data-msg-required="It looks like you forgot to add the CSV export name." aria-required="true" dmx-bind:aria-invalid="invalid" aria-describedby="dmxValidatorErrorfmmodalExportCSVTicketsprexport_name" maxlength="250" data-msg-maxlength="Please enter no more than 250 characters.">

                            <div id="dmxValidatorErrorfmmodalExportCSVTicketsprexport_name" class="invalid-feedback" class="invalid-feedback">

                            </div>

                        </div>

                    </div>

                    <input id="pr_IDAddExportCSV" name="pr_ID" class="" dmx-bind:value="scProjects.data.qrProjectsSingle.pr_ID" type="hidden">

                    <input id="org_IDAddExportCSV" name="org_ID" class="" dmx-bind:value="scProjects.data.qrProjectsSingle.org_ID" type="hidden">

                    <input id="user_IDAddExportCSV" name="user_ID" class="form-control" dmx-bind:value="scAppSettings.data.qrUserDetails.user_ID" aria-hidden="true" role="presentation" type="hidden">

                    <!-- Export tickets -->

                    <div id="record" is="dmx-repeat" dmx-bind:repeat="scProjects.data.ReportTicketsAll">

                        <input id="inp_org_IDExportCSV" name="org_ID" dmx-bind:id="insp_org_IDExportCSV_{{$index}}" dmx-bind:name="record[{{$index}}][org_ID]" dmx-bind:value="org_ID" type="hidden">

                        <input id="inp_pr_IDExportCSV" name="pr_ID" dmx-bind:id="insp_pr_IDExportCSV_{{$index}}" dmx-bind:name="record[{{$index}}][pr_ID]" dmx-bind:value="pr_ID" type="hidden">

                        <input id="inp_ticket_IDExportCSV" name="ticket_ID" dmx-bind:id="insp_ticket_IDExportCSV_{{$index}}" dmx-bind:name="record[{{$index}}][ticket_ID]" dmx-bind:value="ticket_ID" type="hidden">

                        <input id="inp_ticket_nameExportCSV" name="ticket_name" dmx-bind:id="insp_ticket_nameExportCSV_{{$index}}" dmx-bind:name="record[{{$index}}][ticket_name]" dmx-bind:value="ticket_name" type="hidden">

                        <input id="inp_ticket_priorityExportCSV" name="ticket_priority" dmx-bind:id="insp_ticket_priorityExportCSV_{{$index}}" dmx-bind:name="record[{{$index}}][ticket_priority]" dmx-bind:value="ticket_priority" type="hidden">

                        <input id="inp_ticket_typeExportCSV" name="ticket_type" dmx-bind:id="insp_ticket_typeExportCSV_{{$index}}" dmx-bind:name="record[{{$index}}][ticket_type]" dmx-bind:value="ticket_type" type="hidden">

                        <input id="inp_ticket_complexityExportCSV" name="ticket_complexity" dmx-bind:id="insp_ticket_complexityExportCSV_{{$index}}" dmx-bind:name="record[{{$index}}][ticket_complexity]" dmx-bind:value="ticket_complexity" type="hidden">

                        <input id="inp_ticket_statusExportCSV" name="ticket_status" dmx-bind:id="insp_ticket_statusExportCSV_{{$index}}" dmx-bind:name="record[{{$index}}][ticket_status]" dmx-bind:value="ticket_status" type="hidden">

                        <input id="inp_ticket_severityExportCSV" name="ticket_severity" dmx-bind:id="insp_ticket_severityExportCSV_{{$index}}" dmx-bind:name="record[{{$index}}][ticket_severity]" dmx-bind:value="ticket_severity" type="hidden">

                        <input id="inp_ticket_low_visionExportCSV" name="ticket_low_vision" dmx-bind:id="insp_ticket_low_visionExportCSV_{{$index}}" dmx-bind:name="record[{{$index}}][ticket_low_vision]" dmx-bind:value="ticket_low_vision" type="hidden">

                        <input id="inp_ticket_color_blindExportCSV" name="ticket_color_blind" dmx-bind:id="insp_ticket_color_blindExportCSV_{{$index}}" dmx-bind:name="record[{{$index}}][ticket_color_blind]" dmx-bind:value="ticket_color_blind" type="hidden">

                        <input id="inp_ticket_blindExportCSV" name="ticket_blind" dmx-bind:id="insp_ticket_blindExportCSV_{{$index}}" dmx-bind:name="record[{{$index}}][ticket_blind]" dmx-bind:value="ticket_blind" type="hidden">

                        <input id="inp_ticket_deaf_blindExportCSV" name="ticket_deaf_blind" dmx-bind:id="insp_ticket_deaf_blindExportCSV_{{$index}}" dmx-bind:name="record[{{$index}}][ticket_deaf_blind]" dmx-bind:value="ticket_deaf_blind" type="hidden">

                        <input id="inp_ticket_deafExportCSV" name="ticket_deaf" dmx-bind:id="insp_ticket_deafExportCSV_{{$index}}" dmx-bind:name="record[{{$index}}][ticket_deaf]" dmx-bind:value="ticket_deaf" type="hidden">

                        <input id="inp_ticket_keyboard_onlyExportCSV" name="ticket_keyboard_only" dmx-bind:id="insp_ticket_keyboard_onlyExportCSV_{{$index}}" dmx-bind:name="record[{{$index}}][ticket_keyboard_only]" dmx-bind:value="ticket_keyboard_only" type="hidden">

                        <input id="inp_ticket_motor_impairedExportCSV" name="ticket_motor_impaired" dmx-bind:id="insp_ticket_motor_impairedExportCSV_{{$index}}" dmx-bind:name="record[{{$index}}][ticket_motor_impaired]" dmx-bind:value="ticket_motor_impaired" type="hidden">

                        <input id="inp_ticket_speech_impairedExportCSV" name="ticket_speech_impaired" dmx-bind:id="insp_ticket_speech_impairedExportCSV_{{$index}}" dmx-bind:name="record[{{$index}}][ticket_speech_impaired]" dmx-bind:value="ticket_speech_impaired" type="hidden">

                        <input id="inp_ticket_cognitively_impairedExportCSV" name="ticket_cognitively_impaired" dmx-bind:id="insp_ticket_cognitively_impairedExportCSV_{{$index}}" dmx-bind:name="record[{{$index}}][ticket_cognitively_impaired]" dmx-bind:value="ticket_cognitively_impaired" type="hidden">

                        <input id="inp_ticket_issue_descriptionExportCSV" name="ticket_issue_description" dmx-bind:id="insp_ticket_issue_descriptionExportCSV_{{$index}}" dmx-bind:name="record[{{$index}}][ticket_issue_description]" dmx-bind:value="ticket_issue_description.stripTags()" type="hidden">

                        <!-- here is whre the issue starts -->

                        <input id="inp_ticket_issue_impactExportCSV" name="ticket_issue_impact" dmx-bind:id="insp_ticket_issue_impactExportCSV_{{$index}}" dmx-bind:name="record[{{$index}}][ticket_issue_impact]" dmx-bind:value="ticket_issue_impact.stripTags()" type="hidden">

                        <input id="inp_ticket_test_case_descriptionExportCSV" name="ticket_test_case_description" dmx-bind:id="insp_ticket_test_case_descriptionExportCSV_{{$index}}" dmx-bind:name="record[{{$index}}][ticket_test_case_description]" dmx-bind:value="ticket_test_case_description.stripTags()" type="hidden">

                        <input id="inp_ticket_assumptions_and_pre_conditionExportCSV" name="ticket_assumptions_and_pre_condition" dmx-bind:id="insp_ticket_assumptions_and_pre_conditionExportCSV_{{$index}}" dmx-bind:name="record[{{$index}}][ticket_assumptions_and_pre_condition]" dmx-bind:value="ticket_assumptions_and_pre_condition.stripTags()" type="hidden">

                        <input id="inp_ticket_test_dataExportCSV" name="ticket_test_data" dmx-bind:id="insp_ticket_test_dataExportCSV_{{$index}}" dmx-bind:name="record[{{$index}}][ticket_test_data]" dmx-bind:value="ticket_test_data.stripTags()" type="hidden">

                        <input id="inp_ticket_steps_to_be_executedExportCSV" name="ticket_steps_to_be_executed" dmx-bind:id="insp_ticket_steps_to_be_executedExportCSV_{{$index}}" dmx-bind:name="record[{{$index}}][ticket_steps_to_be_executed]" dmx-bind:value="ticket_steps_to_be_executed.stripTags()" type="hidden">

                        <input id="inp_ticket_expected_resultExportCSV" name="ticket_expected_result" dmx-bind:id="insp_ticket_expected_resultExportCSV_{{$index}}" dmx-bind:name="record[{{$index}}][ticket_expected_result]" dmx-bind:value="ticket_expected_result.stripTags()" type="hidden">

                        <input id="inp_ticket_actual_result_markExportCSV" name="ticket_actual_result_mark" dmx-bind:id="insp_ticket_actual_result_markExportCSV_{{$index}}" dmx-bind:name="record[{{$index}}][ticket_actual_result_mark]" dmx-bind:value="ticket_actual_result_mark" type="hidden">

                        <input id="inp_ticket_actual_resultExportCSV" name="ticket_actual_result" dmx-bind:id="insp_ticket_actual_resultExportCSV_{{$index}}" dmx-bind:name="record[{{$index}}][ticket_actual_result]" dmx-bind:value="ticket_actual_result.stripTags()" type="hidden">

                        <input id="inp_ticket_remediationExportCSV" name="ticket_remediation" dmx-bind:id="insp_ticket_remediationExportCSV_{{$index}}" dmx-bind:name="record[{{$index}}][ticket_remediation]" dmx-bind:value="ticket_remediation.stripTags()" type="hidden">

                        <input id="inp_ticket_current_codeExportCSV" name="ticket_current_code" dmx-bind:id="insp_ticket_current_codeExportCSV_{{$index}}" dmx-bind:name="record[{{$index}}][ticket_current_code]" dmx-bind:value="ticket_current_code.stripTags()" type="hidden">

                        <input id="inp_ticket_propose_codeExportCSV" name="ticket_propose_code" dmx-bind:id="insp_ticket_propose_codeExportCSV_{{$index}}" dmx-bind:name="record[{{$index}}][ticket_propose_code]" dmx-bind:value="ticket_propose_code.stripTags()" type="hidden">

                        <input id="inp_ticket_propose_code_CSSExportCSV" name="ticket_propose_code_CSS" dmx-bind:id="insp_ticket_propose_code_CSSExportCSV_{{$index}}" dmx-bind:name="record[{{$index}}][ticket_propose_code_CSS]" dmx-bind:value="ticket_propose_code_CSS.stripTags()" type="hidden">

                        <input id="inp_ticket_propose_code_JSExportCSV" name="ticket_propose_code_JS" dmx-bind:id="insp_ticket_propose_code_JSExportCSV_{{$index}}" dmx-bind:name="record[{{$index}}][ticket_propose_code_JS]" dmx-bind:value="ticket_propose_code_JS.stripTags()" type="hidden">

                        <input id="inp_ticket_propose_code_HTMLExportCSV" name="ticket_propose_code_HTML" dmx-bind:id="insp_ticket_propose_code_HTMLExportCSV_{{$index}}" dmx-bind:name="record[{{$index}}][ticket_propose_code_HTML]" dmx-bind:value="ticket_propose_code_HTML" type="hidden">

                        <input id="inp_ticket_WCAGreferenceExportCSV" name="ticket_WCAGreference" dmx-bind:id="insp_ticket_WCAGreferenceExportCSV_{{$index}}" dmx-bind:name="record[{{$index}}][ticket_WCAGreference]" dmx-bind:value="ticket_sci_success_criteria+' (Level '+ticket_sci_conformance_level+') ('+ticket_sci_version+')'" dmx-repeat:repeatwcagreference="qrTicketsSCIAll" type="hidden">

                        <input id="inp_ticket_ScreenshotsExportCSV" name="ticket_Screenshots" dmx-bind:id="insp_ticket_ScreenshotsExportCSV_{{$index}}" dmx-bind:name="record[{{$index}}][ticket_Screenshots]" dmx-bind:value="'https://digita11yaccessible.a11yn.io/org_files/'+org_ID+'/'+pr_ID+'/screenshot/'+ticket_ss_img" dmx-repeat:repeatscreenshots="qrTicketshotsAll" type="hidden">

                    </div>

                </div>

                <div class="modal-footer">

                    <div class="float-end">

                        <div class="input-group">

                            <button type="button" class="btn btn-outline-primary" data-bs-dismiss="modal">

                                <span dmx-show="(scAppSettings.data.qrUserLanguage.user_language == 'en')">

                                    Cancel

                                </span>

                                <span dmx-show="(scAppSettings.data.qrUserLanguage.user_language == 'fr')">

                                    Annuler

                                </span>

                            </button>

                            <button class="btn btn-primary disabled" dmx-show="var_AddExportCSVClick.value == 1)">

                                <div class="spinner-border spinner-border-sm text-info me-2" role="status">

                                    <span dmx-show="(scAppSettings.data.qrUserLanguage.user_language == 'en')">

                                        <span class="sr-only">Saving...</span>

                                    </span>

                                    <span dmx-show="(scAppSettings.data.qrUserLanguage.user_language == 'fr')">

                                        <span class="sr-only">Économie...</span>

                                    </span>

                                </div>

                            </button>

                            <button type="submit" class="btn btn-primary" dmx-show="(var_AddExportCSVClick.value == 0)" dmx-on:click="!var_AddExportCSVClick.setValue(1)" dmx-bind:disabled="!modalExportCSVTickets.fmmodalExportCSVTickets.prexport_nameAdd.value">

                                <span dmx-show="(scAppSettings.data.qrUserLanguage.user_language == 'en')">

                                    Save

                                    <span class="sr-only">

                                        export tickets to CSV

                                    </span>

                                </span>

                                <span dmx-show="(scAppSettings.data.qrUserLanguage.user_language == 'fr')">

                                    Enregistrer

                                    <span class="sr-only">

                                        les tickets d'exportation au format CSV

                                    </span>

                                </span>

                            </button>

                        </div>

                    </div>

                </div>

            </form>'

This is how the server connect looks:

I kindly request the assistance of the Wappler community to help me identify the cause of this limitation and provide guidance on how to resolve it. Any insights, suggestions, or experiences related to multi-record inserts in Wappler would be greatly appreciated.

Thank you in advance for your support!

@patrick @Teodor any help will be much appreciated, I am not really sure what I am doing wrong, bu have tried everything I can think of.
Thanks
J

I had a look but can’t see anything straight off the bat.

Have you tried setting a counter in the repeat and then outputting that to see how many times the repeat is running? That would at least let you know if the issue is in getting the data to the repeat, or if it’s in the database insert step.

1 Like

HI @Heather_Mann, thank you so much for looking into it.
Yes, I have set up a counter in the repeat region and all of the records show… I have tried several combinations, so I know that the data integrity is good. But for some reason it looks like only 5 fields can be process at one time. So I have tried different fields combinations to see if maybe one of them may be the problem, but it looks like I can only do 5 fields after that the multi insert no longer works well.
Best regards
J

So you’re limited to 5 fields and 15 records? Ooph. That’s a strange one.

Have you looked at the code for the server action, or tried recreating it from scratch?

I know, not really sure what is happening there ether. I did try re-building it from the start. and still nothing.