Edited: 9/23/2018 4:54 AM
Picture Placeholder: System Account
System Account
How to save repeater's rows in a different list?

​How could I save the repeater's rows in a different list using a custom button?

Picture: Sergio Schinoff
  • Sergio Schinoff
/_layouts/15/images/person.gif" alt="Picture Placeholder: System Account" />
System Account

​How could I save the repeater's rows in a different list using a custom button?

7819/23/2018 1:53 AM9/23/2018 4:54 AMNoCodes & Scripts
6.85769291705031
19/20/2018 8:29 AM
Posted: 9/23/2018 3:28 AM
Picture: Jim Hidson
Jim Hidson
You have two ways to do that:

 

The First Way)

By adding a custom button in the repeater row, in this button you can add a rule with type action event: onchange, and add the following script in it:

function addTheRow(){

var status=newListItem('/','Employee',['Title','EmpName','EmpNo','JobTitle'],[getValue(TextBox3),getValue(TextBox6),getValue(TextBox2),getValue(TextBox7)])

}

onClick(Button1,addTheRow())

 

The Second Way)

By adding a custom button outside the repeater to get all the rows data and save them in a list by looping through them. In order to do that follow the following steps:

Let's say you have four controls in the repeater [Title, Name, Num, Job]

  1. Create a [form variable] for each control [titleArray, nameArray, NumArray, JobArray]
  2. Add a rule on every control or put them together on one rule on the repetear with type action event: onchange with the following code:
    formVariableName=getRepeaterData(controlID)
    ie. titleArray= getRepeaterData(Title)
  3. In the custom button add a new rule with type action event: onchange with the following script:
function addAllRows(){

var titleArry=titleArray.split(',')

var nameArry=nameArray.split(',')

var NumArry=NumArray.split(',')

var JobArry=JobArray.split(',')

for(var i=0;i<titleArry.length;i++){

  var status=newListItem('/','Employee',['Title','EmpName','EmpNo','JobTitle'],[titleArry[i],nameArry[i],NumArry[i],JobArry[i]])

alert(status)

}

}

onClick(Button2,addAllRows())

 

This should do the job, take into consideration that alert(status) is to make sure that saving has been successfully done, you can replace it with if statement to show a custom success/fail messages.

 



Picture: Jim Hidson
  • Jim Hidson
http://www.itlaq.com:80/my/User%2520Photos/Profile%2520Pictures/jim_MThumb.jpg?t=63627189186" alt="Picture: Jim Hidson" />
Jim Hidson
You have two ways to do that:

 

The First Way)

By adding a custom button in the repeater row, in this button you can add a rule with type action event: onchange, and add the following script in it:

function addTheRow(){

var status=newListItem('/','Employee',['Title','EmpName','EmpNo','JobTitle'],[getValue(TextBox3),getValue(TextBox6),getValue(TextBox2),getValue(TextBox7)])

}

onClick(Button1,addTheRow())

 

The Second Way)

By adding a custom button outside the repeater to get all the rows data and save them in a list by looping through them. In order to do that follow the following steps:

Let's say you have four controls in the repeater [Title, Name, Num, Job]

  1. Create a [form variable] for each control [titleArray, nameArray, NumArray, JobArray]
  2. Add a rule on every control or put them together on one rule on the repetear with type action event: onchange with the following code:
    formVariableName=getRepeaterData(controlID)
    ie. titleArray= getRepeaterData(Title)
  3. In the custom button add a new rule with type action event: onchange with the following script:
function addAllRows(){

var titleArry=titleArray.split(',')

var nameArry=nameArray.split(',')

var NumArry=NumArray.split(',')

var JobArry=JobArray.split(',')

for(var i=0;i<titleArry.length;i++){

  var status=newListItem('/','Employee',['Title','EmpName','EmpNo','JobTitle'],[titleArry[i],nameArry[i],NumArry[i],JobArry[i]])

alert(status)

}

}

onClick(Button2,addAllRows())

 

This should do the job, take into consideration that alert(status) is to make sure that saving has been successfully done, you can replace it with if statement to show a custom success/fail messages.

 



Sergio Schinoff5309/23/2018 3:28 AM9/23/2018 3:28 AM
9/19/2018 7:49 AM1
Sergio Schinoff