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 / Efficient way to creat...
Power Apps
Answered

Efficient way to create new items in a sharepoint list from a collection

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hi All,

 

I have created a power app and my requirement is as mentioned below

 

When a new item is created in List 1, i need to create 10 pre defined items in List 2. Also List 2 has a ParentID column which should refer to the ID from List 1 when an new is item created.

 

Trying to understand the most efficient way for doing this.

 

What i am doing now is,

  1. When my power apps loads i have a collection which has the 10 pre defined items .
  2. Created a new Item form
  3. On success of when a new item is created i am using UpdateIf to update one of the collection column to the ID of the newly created item
  4. Then using Patch( sharepoint list name, Collection Name), the 10 pre defined items get created in List 2.
  5. It takes about 5 seconds for this operation to complete

This seems to work but in the Patch documentation it says to use Defaults() to create new item. So i am unsure if this is the right way of doing it or if there is a better and efficient way.

 

Any inputs will be helpful

Categories:
I have the same question (0)
  • WarrenBelz Profile Picture
    155,540 Most Valuable Professional on at

    Hi @Anonymous ,

    You did not supply any code, but to answer your question Patch using Defaults(ListName) as the parameter is the correct way of creating new records in a list.

    If all the fields in the collection are contained in name and data type in the List, you can also use

    Collect(
     ListName,
     CollectionName
    )

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hi @WarrenBelz 

     

    thanks for checking this. May be i should have explained better.

     

    I have 2 sharepoint Lists, List 1 & List 2.
    I have another list named Documents which has 10 items ( these are my pre defined items what i want to be copied each time to List 2 when an item is created in List 1)

     

    I have created an app to create item for List 1

    OnStart 

    ClearCollect(colDocument,ShowColumns(Filter('Documents',DocType ="Account"),"DocName","ParentID"))

     

    Form 1 is to create item in List 1


    OnSuccess of Form1
    UpdateIf(colDocument,true,{ParentID: Form1.LastSubmit.ID});
    Patch('List2',colAccountDoc)

     

    Like i said this created new entries in List 2 without using the Defaults()

  • WarrenBelz Profile Picture
    155,540 Most Valuable Professional on at

    Hi @Anonymous ,

    There are many ways of achieving the same result in Power Apps. Your Patch code should work if all the fields from the collection line up with the List (Collect does as well), but I have found the Patch syntax buggy in the past and stick with what I know always works. Your UpdateIf code is also interesting as you would normally use Collect() for what you are doing.

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hi @WarrenBelz , are you suggesting to just use Collect(). If yes was wondering how could i update the ParentID column. I would still need to use the updateif function

     

    I tried Updateif and Collect(). It works but sower when compared to Updateif and Patch()

  • Verified answer
    WarrenBelz Profile Picture
    155,540 Most Valuable Professional on at

    @Anonymous ,

    I generally only use UpdateIf() when I want to update multiple matching items (Patch otherwise), but it certainly works on a single item. Collect works for updating both a collection and (when the fields align) a list as does Patch (your code) on a list in the same scenario. 

    Having said this, what you use is at times a personal preference if both options work effectively. As most of my apps are used in the field and all data succeeding to write is far more important than a few milliseconds in performance, I use Patch() a lot.

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

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 April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Valantis Profile Picture

Valantis 408

#2
timl Profile Picture

timl 340 Super User 2026 Season 1

#3
Vish WR Profile Picture

Vish WR 319

Last 30 days Overall leaderboard