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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / How To Patch create mu...
Power Apps
Unanswered

How To Patch create multiple records

(0) ShareShare
ReportReport
Posted on by 43

Hi Team,

 

I want to know how i can create multiple records into my sharepoint list using patch function on my button in power apps.

I have form with dropdown fields . Based on the selection of different fields , user will click button below.  I have written below code on my patch button. It duplicates the records in the list instead of multiple different records.

KanwalKaurSaini_1-1625393593901.png

                                                                                            

KanwalKaurSaini_0-1625393558223.png

Please assist.

 

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

    HI @KanwalKaurSaini ,

    You need a structure like this

    ForAll(
     Collnew As aPatch,
     Patch(
     'Master data', 
     Defaults('Master data'), 
     {
     Title:aPatch.Title,
     Area:aPatch.Area,
     Month:aPatch.Month,
     Year:aPatch.Year,
     Country:aPatch.Country, 
     Datemaster:aPatch.Datemaster
     }
     )
    )

     

    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.

  • KanwalKaurSaini Profile Picture
    43 on at

    Hi @WarrenBelz ,

     

    It is not working .giving me error .

    KanwalKaurSaini_0-1625461034273.png

     

  • WarrenBelz Profile Picture
    153,127 Most Valuable Professional on at

    @KanwalKaurSaini ,

    Free-typed (now corrected) - try capital A is As.

  • KanwalKaurSaini Profile Picture
    43 on at

    Hi ,

     

    It is duplicating same records n number of times instead of creating different records . Basically I want to create different records in my list with powerapps .

  • WarrenBelz Profile Picture
    153,127 Most Valuable Professional on at

    @KanwalKaurSaini ,

    Assuming you have different records in colNew, this will certainly write each one as a new record in 'Master Data'

    ForAll(
     Collnew As aPatch,
     Patch(
     'Master data', 
     Defaults('Master data'), 
     {
     Title:aPatch.Title,
     Area:aPatch.Area,
     Month:aPatch.Month,
     Year:aPatch.Year,
     Country:aPatch.Country, 
     Datemaster:aPatch.Datemaster
     }
     )

    Have you checked the colleciton?

     

    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.

     

  • KanwalKaurSaini Profile Picture
    43 on at

    Hi ,

     

    I checked the collection, it stores the same data multiple times. 😞 

  • WarrenBelz Profile Picture
    153,127 Most Valuable Professional on at

    @KanwalKaurSaini ,

    There is something else wrong here - that code will store each record of collNew as a new record in 'Master data'.

    Please post the exact code you are using (in Text) and also go to View > Collections > collNew and post a screen shot of the contents.

  • KanwalKaurSaini Profile Picture
    43 on at

    Hi ,

     

    I first added code on app start property as "ClearCollect(collnew,'Master data').

    on the Item property of form , I wrote LookUp('Master data',ID=Gallery1.Selected.ID)

    then on the patchbutton I wrote this ForAll(
    collnew As aPatch,
    Patch(
    'Master data',
    Defaults('Master data'),
    {
    Title:aPatch.Title,
    Area:aPatch.Area,
    Month:aPatch.Month,
    Year:aPatch.Year,
    Country:aPatch.Country,
    Datemaster:aPatch.Datemaster
    }
    )
    )

      

    I also tried with this code .It worked once but this is also not working. ForAll(
    ShowColumns(Collection1,"Title","Year","Month","Area","Country","Datemaster"),
    Patch('Master data',ThisRecord,{Title:Title,Year:Year,Month:Month,Area:Area,Country:Country,Datemaster:Datemaster}
    )
    )

  • WarrenBelz Profile Picture
    153,127 Most Valuable Professional on at

    @KanwalKaurSaini ,

    I am lost as to why this is not working. The ShowColumns() in the second code would have no effect on the result and actually is not necessary (without it all columns are available for the Patch). The problem with the rest of the  second code is ambiguity (which is why I used the As statement in mine).

    You did not include a screenshot of collNew.

     

    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.

  • KanwalKaurSaini Profile Picture
    43 on at

    Hi ,

     

    Please find the screenshot below

    KanwalKaurSaini_0-1625812513110.png

     

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 765 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 272

Last 30 days Overall leaderboard