cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
syl_kn
Level: Powered On

Save Multiple Records to SharePoint List

Hi All,


Wondering if I can get some help with my first app.   

 

I've made a PowerApp that connects to SharePoint list and it can successfully save entries from the PowerApp to my SharePoint List.

 

However, what I would like my app to do is save multiple entries in one go, rather than having to enter in 10 different entries.   

 

In the attached example I can easily save one entry per employee number.    But, if I want to save 10 entries I have to entre the 10 different employee numbers and save the data 10 times (the only data that changes is the employee number, all other data remains the same per entry).   What I would like to do is copy in a list of 10 different employee numbers, then select the dates and other fields and have each employee number saved back to my SharePoint List with the dates..etc all in one click.     Is this kind of thing possible with PowerApps, if so, how can I do it? 


I have been experimenting with Collections and I think I might need to use that somehow, but I'm not sure where to being.


Thanks in advance,

syl_kn 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
syl_kn
Level: Powered On

Re: Save Multiple Records to SharePoint List

Thanks!  Soultion is: 



ForAll(
Split(DataCardValue14.Text, Char(10)), /* <-- Split the Employee Numbers text string into an array */
Patch( 'YourSPListDataSource', Defaults('YourSPListDataSource'), { Employee_x0020_Number:Result, Start_x0020_Date:DataCardValue2.SelectedDate, End_x0020_Date:DataCardValue3.SelectedDate, Reason_x0020_Code:DataCardValue4.Selected.Value, Comment:DataCardValue5.Text, BU:DataCardValue6.Selected.Value } )
)

View solution in original post

10 REPLIES 10
syl_kn
Level: Powered On

Re: Save Multiple Records to SharePoint List

Can anyone help? Think I might need to use for all and split perhaps?

Thanks again
Community Support Team
Community Support Team

Re: Save Multiple Records to SharePoint List

Hi @syl_kn,

Do you want to add multiple records within your SP list data source at once time?

 

If you want to add multiple records within your SP list data source at once time, I think the Patch function could achieve your needs.

Please check and see if the following thread would help in your scenario:

https://powerusers.microsoft.com/t5/General-Discussion/Submitting-multiple-forms-to-a-single-table/t...

On your side, you should take a try with the following workaround:

Set the OnSelect property of the "Submit" button to following workaround:

 

Patch(                                    /* <-- Employee1 */
'YourSPListDataSource',
Defaults('YourSPListDataSource'),
{
Employee_x0020_Number:"1112236", /* <-- Type the Employee number for first employee */
Start_x0020_Date:DataCardValue2.SelectedDate,
End_x0020_Date:DataCardValue3.SelectedDate,
Reason_x0020_Code:DataCardValue4.Selected.Value,
Comment:DataCardValue5.Text,
BU:DataCardValue6.Selected.Value
}
);
Patch( /* <-- Employee2 */
'YourSPListDataSource',
Defaults('YourSPListDataSource'),
{
Employee_x0020_Number:"1112237", /* <-- Type the Employee number for second employee */
Start_x0020_Date:DataCardValue2.SelectedDate,
End_x0020_Date:DataCardValue3.SelectedDate,
Reason_x0020_Code:DataCardValue4.Selected.Value,
Comment:DataCardValue5.Text,
BU:DataCardValue6.Selected.Value
}
);
Patch( /* <-- Employee3 */
'YourSPListDataSource',
Defaults('YourSPListDataSource'),
{
Employee_x0020_Number:"1112238", /* <-- Type the Employee number of third Employee */
Start_x0020_Date:DataCardValue2.SelectedDate,
End_x0020_Date:DataCardValue3.SelectedDate,
Reason_x0020_Code:DataCardValue4.Selected.Value,
Comment:DataCardValue5.Text,
BU:DataCardValue6.Selected.Value
}
);
...
...
Patch( /* <-- Employee10 */
'YourSPListDataSource',
Defaults('YourSPListDataSource'),
{
Employee_x0020_Number:"1112246", /* <-- Type the Employee number for 10th Employee */
Start_x0020_Date:DataCardValue2.SelectedDate,
End_x0020_Date:DataCardValue3.SelectedDate,
Reason_x0020_Code:DataCardValue4.Selected.Value,
Comment:DataCardValue5.Text,
BU:DataCardValue6.Selected.Value
}
)

Note: The DataCardValue2, DataCardValue3, ..., DataCardValue6 are all controls within the Edit form. e.g. The DataCardValue2 represents the DataPicker control within the Start Date Data card, the DataCardValue4 represents the Drop down/Combo box control within the Reason Code Data card.

 

More details about the Patch function in PowerApps, please check the following article:

Patch function

 

Best regards,

Kris

 

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
syl_kn
Level: Powered On

Re: Save Multiple Records to SharePoint List

Hi 

 

 

 

 

Community Support Team
Community Support Team

Re: Save Multiple Records to SharePoint List

Hi @syl_kn,

Do you want to type multiple Employee Numbers within the TextInput control within the Employee Number Data card?

 

If you want to type multiple Employee Numbers (50) within the TextInput control within the Employee Number Data card, you could consider type multiple Numbers with comma (,) as the sperator. You should type the Employee Numbers as below:

11111111,
11111112,
11111113,
...
11111126,
11111127,
...
11111161

3.JPG

Then modify your formula within the Items property of the Gallery control to following:

ForAll(
Split(DataCardValue14.Text,","), /* <-- Split the Employee Numbers text string into an array */
Patch( 'YourSPListDataSource', Defaults('YourSPListDataSource'), { Employee_x0020_Number:Result, Start_x0020_Date:DataCardValue2.SelectedDate, End_x0020_Date:DataCardValue3.SelectedDate, Reason_x0020_Code:DataCardValue4.Selected.Value, Comment:DataCardValue5.Text, BU:DataCardValue6.Selected.Value } )
)

Note: The DataCardValue14 represents the TextInput control within the Employee Number Data card.

 

More details about the ForAll function in PowerApps, please check the following article:

ForAll function

 

Best regards,

Kris

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
syl_kn
Level: Powered On

Re: Save Multiple Records to SharePoint List

Yes! This is basically the idea and I've tried your example and it works.    I looking for a way to split the string every 8 characters because a list of numbers will be pasted from Excel straight into this app.     Looking at the split function I cant see a way to split at every carriage return

 

 

Community Support Team
Community Support Team

Re: Save Multiple Records to SharePoint List

Hi @syl_kn,

Do you want to split a string every 8 characters within PowerApps?

If you want to split a string every 8 characters within PowerApps, I afraid that there is no way to achieve your needs in PowerApps currently.

If you would like this feature to be added in PowerApps, please submit an idea to PowerApps Ideas Forum:

https://powerusers.microsoft.com/t5/PowerApps-Ideas/idb-p/PowerAppsIdeas

 

Best regards,

Kris

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
syl_kn
Level: Powered On

Re: Save Multiple Records to SharePoint List

Thank You! I have added the idea.  I dont suppose there is any other way to manipulate the data to insert a comma or someother way would enable this to work with Split.   

syl_kn
Level: Powered On

Re: Save Multiple Records to SharePoint List

I worked it out!  

 

This will split at every new line

Split(DataCardValue14.Text, Char(10))

 

Community Support Team
Community Support Team

Re: Save Multiple Records to SharePoint List

Hi @syl_kn,

Have you solved your problem?

 

If you have solved your problem, please go ahead and click “Accept as Solution” so that this thread will be marked for other users to easily identify. 

 

Best regards,

Kris

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors
Users Online
Currently online: 339 members 5,999 guests
Please welcome our newest community members: