​​How to save repeater's rows into a different list?

Last Update: June 22, 2018

In this use case we will show you how to save repeater’s rows in another list.
We have two ways to accomplish this:

  1. Method #1: By adding a custom Button control inside the repeater. The related row (only one row) will be saved into the list when the user clicks on this button. In this Button control, we will add a rule to save the related rows into a SP list.
  2. Method #2: By adding a custom Button control outside the repeater to get all the row's data and save them in a list by looping through them. In this Button control we will add two rules, the first is to save repeater’s rows into form variables and the 2nd to save all rows into a SP list.

You can use both methods to create Parent-Child or what called Master-Details list items.

Before starting describing both methods, you have to create a SP list named "Empoyees_Text" with the following single line of text columns: Num, Name and Job.

Method #1: Here are the steps on how to do the first method:

  1. Open the form in design mode.
  2. Add the following controls in the form:
    How to save repeater's rows into a different list1.jpg
  3. Select btnAddRowToEmployeeList control.
  4. In the Rules pane, click on the Add icon to add a new rule, the Rule Manager dialog will open.
    How to auto-shifting Panel control in a form2.jpg
  5. Add rule as follows:
    A. Change the Rule Name as desired.
    B. Change the Rule Type to Action.
    C. Change the Event Type to onClick.
    D. In the Action section, type the following script:
         var status = newListItem('/','Employees_Test', ['Title', 'Num', 'Name', 'Job'], [getValue(txtTitle), getValue(txtNum), getValue(txtName), getValue(txtJob)])
    E. Click on the Save button to save the rule.
    Note: You can use Assistance Panel to help you adding functions and related parameters, form variables and form controls to Conditions and/or Actions sections.
  6. Test the form by clicking on the Preview button in the View Group.

Method #2: Here are the steps on how to do the second method:

  1. Open the form in design mode.
  2. Add the following controls in the form:
    How to save repeater's rows into a different list2.jpg
  3. Select Repeater5 control.
  4. In the Rules pane, click on the Add icon to add a new rule, the Rule Manager dialog will open.
    How to auto-shifting Panel control in a form2.jpg
  5. Add a new rule to save repeater’s rows into form variables as follows:
    A. Change the Rule Name as desired.
    B. Change the Rule Type to Action.
    C. Change the Event Type to onChange. Check "Execute if event triggered only on this control".
    D. In the Action section, type the following script:
         varNumArray = getRepeaterData(txtNum)
         varNameArray = getRepeaterData(txtName)
         varTitleArray = getRepeaterData(txtTitle)
         varJobArray = getRepeaterData(txtJob)
    E. Click on the Save button to save the rule.
    Note: You can use Assistance Panel to help you adding functions and related parameters, form variables and form controls to Conditions and/or Actions sections.
  6. Select btnAddAllRowsToEmployeeList control.
  7. In the Rules pane, click on the Add icon to add a new rule, the Rule Manager dialog will open.
    How to auto-shifting Panel control in a form2.jpg
  8. Add new rule to save all repeater’s rows into a SP list as follows:
    A. Change the Rule Name as desired.
    B. Change the Rule Type to Action.
    C. Change the Event Type to onClick.
    D. In the Action section, type the following script:
         var varNumArry = varNumArray.split(',')
         var varNameArry = varNameArray.split(',')
         var varTitleArry = varTitleArray.split(',')
         var varJobArry = varJobArray.split(',')

         for(var i=0;i<varTitleArry.length;i++){
         var status = newListItem('/','Employees_Test',['Title','Num','Name','Job'],[varTitleArry[i],varNumArry[i],varNameArry[i],varJobArry[i]])

        //alert(status)
        }
        }

    E. Click on the Save button to save the rule.
  9. Test the form by clicking on the Preview button in the View Group.

Related Resources:
These resources may not reflect the same exact case steps.
How to create master-details "parent-child" form?
How to create a cascade delete master-details form?
How to auto-shifting Panels control in the form?