web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Writing a collection t...
Power Apps
Answered

Writing a collection to a SP List using Collect()

(0) ShareShare
ReportReport
Posted on by 11

Hi all,

 

I have built a Powerapps survey off of a previous template. The app creates two different collections. One with the tool name "Tool", any comments "Comments", and the user's skill level "SkillLevel." My second collection takes the user's interest in different tool categories and lets them assign a rank-order for each one. The two columns in this collection are the tool name "LearnMoreTool" and the rank the user gave it "LearnMoreRanking."

 

I have created two SharePoint Lists with the respective column names. The Lists exactly match the columns aside from me not being able to remove the "Title" column that defaults as the first column. PowerApps recognizes the SharePoint and there are no formula issues when I create the data source connection with the SP Lists.

 

To write the data from the collection I am using two Collect() statements:

 

Collect('SPList1', 'Collection1')

Collect('SPList2', 'Collection2')

 

When I test the survey, the collect statements run but nothing is written to the SP List. I have ran this app using the Monitor and no errors arise. The command line tells me that the rows were successfully written to the SP List, but nothing actually populates. Has anybody ran into a similar issue? The Collect() statement should work because I am writing a collection into a SP List. I should not need to patch. I have followed the below video as a guide:

 

https://www.youtube.com/watch?v=MclJ_O9HvJQ

 

Thank you for your help.

Categories:
I have the same question (0)
  • FabianAckeret Profile Picture
    975 on at

    Hi @devinb 

     

    Is there a reason why you don't want to use Patch?

     

    This should help you --> it will create new records.

    Patch(
     'SPList1',
     Defaults('SPList1'),
     'Collection1'
    )
    
    Patch(
     'SPList2',
     Defaults('SPList2'),
     'Collection2'
    )

     

    I hope this helps.

     

    Kind regards,

  • devinb Profile Picture
    11 on at

    Hello @FabianAckeret,

     

    When I attempt to use the above Patch function I get the following error: "Invalid argument type (Table). Expecting a Record value instead." Each of my collections contain both multiple rows and columns. Does this affect using Patch() to write to a SP List?

  • Verified answer
    FabianAckeret Profile Picture
    975 on at

    Hi @devinb 

     

    My mistake - it was quite late when I was writing the response.

    Try this - it's just the patch equivalent of Collect().

     

     

    Patch(
     'SPList1',
     'Collection1'
    )
    
    Patch(
     'SPList2',
     'Collection2'
    )

     

     

     

    If its still not working, are you sure that the column names are the same? I'm not quite sure about this, but I think even the internal names need to be identical. Say, when you create a column in SharePoint with the name Skill Level and then later go ahead and rename it to SkillLevel, the internal name is still going to be Skill Level -respectively Skill_x0020_Level - since whitespaces are being replaced by _x0020_. 

     

    If you patch an entire collection, those things need to be super exact as otherwise there is no proper match.

     

    Kind regards,

     

  • devinb Profile Picture
    11 on at

    Thank you @FabianAckeret . I deleted and recreated each SharePoint list which seemed to fix the problem. My original solution using Collect() functioned correctly, but your Patch() solution should also work when writing to SP Lists. Thanks for your help!

    My belief is similar to what you shared. When I originally created each list I may have modified some of the columns which caused the original names to be changed and it wasn't picked up by PowerApps.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Valantis Profile Picture

Valantis 494

#2
WarrenBelz Profile Picture

WarrenBelz 352 Most Valuable Professional

#3
11manish Profile Picture

11manish 323

Last 30 days Overall leaderboard