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

Saving Data from a Collection to a Sharepoint list

Some reason I can not get my collecitons to send data to a sharepoint list I created. I have the same name columns for my collection and sharepoint list

 

For the my collection I have a columns that are called

Title, DateOfReferral, CustomerPhoneNumber,Email,BestToCall, State, Zip, AreaOfInterest

 

and for the sharepoint list is the same names for the columns. 

Title, DateOfReferral, CustomerPhoneNumber,Email,BestToCall, State, Zip, AreaOfInterest

 

When i save the data for my colleciton i am using 

Collect(CollectAdvisory,{Title: CustomerName.Text, DateofReferral: 'Date of Referral'.SelectedDate, CustomerPhoneNumber: CustomerPhoneNumber.Text,  Email: Email.Text, BestToCall: bestTToCall.Text, City: City.Text, State: states.SelectedText, Zip:Zip.Text, AreaOfInterest: ListBox3.SelectedItems });

 and that will save all my data to a collection. I am using a text input, dropdown, list box and date picker that is collecting data for me.

 

The code i am using to send the data to sharepoint list is 

Collect(advisory, CollectAdvisory)

 

I was only able to get the Title column to receieve data but not any of the others. I have already connected the sharepoint list database so it should be able to see the columns. Not too sure what else to try. Any help is appreicated.

1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

Re: Saving Data from a Collection to a Sharepoint list

You'll want to use Patch() rather than Collect. You can find the syntax here:

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-patch

The key is to use defaults(datasource) as the second parameter to create a new record and something like Lookup() to identify a specific record is your want to update a record.

 

If you do want to use Collect, make sure that the Internal column names match the ones you are using and alls that the data types match completement.  Depending on what you are doing I suspect the DateOfReferral, Email, and AreaOfInterst are goin g to cause issues since they are complex data types.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

View solution in original post

11 REPLIES 11
Super User
Super User

Re: Saving Data from a Collection to a Sharepoint list

You'll want to use Patch() rather than Collect. You can find the syntax here:

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-patch

The key is to use defaults(datasource) as the second parameter to create a new record and something like Lookup() to identify a specific record is your want to update a record.

 

If you do want to use Collect, make sure that the Internal column names match the ones you are using and alls that the data types match completement.  Depending on what you are doing I suspect the DateOfReferral, Email, and AreaOfInterst are goin g to cause issues since they are complex data types.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

View solution in original post

alex5p
Level: Powered On

Re: Saving Data from a Collection to a Sharepoint list

Thank you for your help. I had tried to get rid of dateofreferral, state adn area of interest since they were dropdown and a list and it worked. I just now need to figure out how i can save the data from those special fields

Super User
Super User

Re: Saving Data from a Collection to a Sharepoint list

It can be done using a Patch statement to create or update each record.  Using Patch you can specify the specific format required for each of those special fields.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
alex5p
Level: Powered On

Re: Saving Data from a Collection to a Sharepoint list

Do you know what the code for the a listbox would be getting an error saying expects record but found table.

 

I used

 AreaOfInterest: ListBox3.SelectedItems

 

Patch(advisory, Defaults(advisory), {Title: CustomerName.Text, CustomerPhoneNumber: CustomerPhoneNumber.Text,  Email: Email.Text, BestToCall: bestTToCall.Text,City: City.Text, Zip:Zip.Text, DateOfReferral: 'Date of Referral'.SelectedDate,State: states.SelectedText, AreaOfInterest: ListBox3.SelectedItems})
Super User
Super User

Re: Saving Data from a Collection to a Sharepoint list

Since you are patching to a Multiselect column you need to use this

AreaOfInterest: ListBox3.SelectedItems.Value


-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
alex5p
Level: Powered On

Re: Saving Data from a Collection to a Sharepoint list

I tried that code and it now looks like

 

Patch(advisory, Defaults(essaadvisory), {Title: CustomerName.Text, CustomerPhoneNumber: CustomerPhoneNumber.Text,  Email: Email.Text, BestToCall: bestTToCall.Text,City: City.Text, Zip:Zip.Text, DateOfReferral: 'Date of Referral'.SelectedDate,State: states.SelectedText, AreaOfInterest: ListBox3.SelectedItems.Value})

It came up with an error saying epextec type "table". found type "Error"

 

I included a screenshot of my column setting. Not sure what I am doing wrong. I appreicate all your help.

 

Super User
Super User

Re: Saving Data from a Collection to a Sharepoint list

if you are patching advisory then you should be supplying the defaults for advisory not essaadvisory



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
alex5p
Level: Powered On

Re: Saving Data from a Collection to a Sharepoint list

I copied the code wrong by mistake. I am patching into advisory but still get that error from the above post.

 

 

Patch(advisory, Defaults(advisory), {Title: CustomerName.Text, CustomerPhoneNumber: CustomerPhoneNumber.Text,  Email: Email.Text, BestToCall: bestTToCall.Text,City: City.Text, Zip:Zip.Text, DateOfReferral: 'Date of Referral'.SelectedDate,State: states.SelectedText, AreaOfInterest: ListBox3.SelectedItems.Value})
Super User
Super User

Re: Saving Data from a Collection to a Sharepoint list

Then I'm not sure what is happening for you.  I built a quick prototype with a list box and a multiselect field and it works for me.  So I can't reproduce your error.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Helpful resources

Announcements
firstImage

Microsoft Business Applications Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

firstImage

Demo Extravaganza Championship Voting Open

Voting Ends: October 30, 2019!

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

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

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

Top Kudoed Authors
Users Online
Currently online: 372 members 4,575 guests
Please welcome our newest community members: