Skip to main content
Community site session details

Community site session details

Session Id : 6tlZ3rnldG1TXigIM/GcdD
Power Apps - Building Power Apps
Answered

Add new item from form in to a collection

Like (0) ShareShare
ReportReport
Posted on 29 Jan 2022 07:51:51 by 159

I create a collection from a list on app start. When i create  or edit an item using  a form  i want to add  this changes or new items  to this collection. (col_Activitati)

I manage to create the formula for edit changes to an item , but i can find how to add new item to collection when i click submit button on the form. Bellow it's the code:

I have 2 buttons on main screen, add for adding new items, when it's click the form is in new mode, and edit and the the form it's in edit mode.

Formula for submit button it's working for the edit mode.

If(FormTask.Mode=FormMode.Edit,

Patch(col_Activitati,LookUp(col_Activitati,ID=Gallery1.Selected.ID),FormTask.Updates), and next must continue with  the else part where  add item to the collection when the form is in new mode.

 

Thank you

Categories:
  • ciprianpopovici Profile Picture
    159 on 03 Feb 2022 at 10:45:32
    Re: Add new item from form in to a collection

    Thank you, it's working. I try to work with collections instead of using data source when show gallery items in this case  , because loading taking long time because of number of items.

  • Verified answer
    WarrenBelz Profile Picture
    148,811 Most Valuable Professional on 30 Jan 2022 at 10:44:48
    Re: Add new item from form in to a collection

    @ciprianpopovici ,

    Yes - you need the name of the list (that was a typo of mine), but what you are doing is a little unusual - try this

    If(
     FormTask.Mode=FormMode.Edit,
     Patch(
     col_Activitati,
     {ID:Gallery1.Selected.ID},
     FormTask.Updates
     ),
     Collect(
     col_Activitati,
     FormTask.Updates
     )
    )

     

    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.

    Visit my blog Practical Power Apps

  • ciprianpopovici Profile Picture
    159 on 30 Jan 2022 at 09:33:28
    Re: Add new item from form in to a collection

    Hello, i test your formula and i modified this line to work, else i have an error of syntax

     

    Patch(
     col_Activitati,
     If(
     FormTask.Mode=FormMode.Edit,
     {ID:Gallery1.Selected.ID},
     Defaults(FormTask) to Defaults(TaskuriCritice)
     ),
     FormTask.Updates
    )

    . TaskuriCritice it's the name of SharePoint List where the data is located. Unfortunately when i add a new item it's not show up automatically in the collection -i have a gallery bound to this collection. When i edit an item the modification show up. How can i refresh the collection to show up new items using the formula on submit button?

  • WarrenBelz Profile Picture
    148,811 Most Valuable Professional on 29 Jan 2022 at 09:53:39
    Re: Add new item from form in to a collection

    Hi @ciprianpopovici ,

    Try this

    Patch(
     col_Activitati,
     If(
     FormTask.Mode=FormMode.Edit,
     {ID:Gallery1.Selected.ID},
     Defaults(YourListName)
     ),
     FormTask.Updates
    )

     

    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.

    Visit my blog Practical Power Apps

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

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 791 Most Valuable Professional

#2
MS.Ragavendar Profile Picture

MS.Ragavendar 410

#3
mmbr1606 Profile Picture

mmbr1606 275 Super User 2025 Season 1

Loading complete