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 / Patch all items from a...
Power Apps
Unanswered

Patch all items from a gallery with updated value / duplicate all items in a gallery

(0) ShareShare
ReportReport
Posted on by 30

Hello, 

I am trying to program an app and need help. 


The Gallery 2_5 shows all items of the table "Fragen". I want all items to be patched in the table again, but with a different value at the column "abschnitt". -> so a duplicate of each item, with the only difference in the "abschnitt" column. 

I get the error: The function ForAll and the Function Patch have some invalid arguments.

 

Code: 

 

ForAll(Gallery2_5.AllItems, 
Patch(Fragen,Defaults(Fragen),
{Bild:Gallery2_5.Selected.Bild,
Type:Gallery2_5.Selected.Type,
Frage:Gallery2_5.Selected.Frage,
Abschnitt: Text(Concatenate(Gallery2_5.Selected.Abschnitt, "new")}))

 

 

Can someone help me?

 

Best wishes, 

Anna

Categories:
  • TheRobRush Profile Picture
    11,128 Moderator on at

    As new items

    Patch(Fragen,
    	ForAll(Gallery2_5.AllItems As stepThrough,
    		{Bild:stepThrough.Bild,
    		Type:stepThrough.Type,
    		Frage:stepThrough.Frage,
    		Abschnitt: Text(Concatenate(stepThrough.Abschnitt, "new")}
    		)
    	)

     

    to update Old items

    Patch(Fragen,
    	ForAll(Gallery2_5.AllItems As stepThrough,
    		{
     ID:stepThrough.ID
     Bild:stepThrough.Bild,
    		Type:stepThrough.Type,
    		Frage:stepThrough.Frage,
    		Abschnitt: Text(Concatenate(stepThrough.Abschnitt, "new")}
    		)
    	)
  • NandiniBhagya20 Profile Picture
    4,667 Super User 2024 Season 1 on at

    Hi @Anna123456 ,
    Try using below formula (there was one missing closing parenthesis) - 

    ForAll(Gallery2_5.AllItems As Data, 
    Patch(Fragen,Defaults(Fragen),
    {Bild: Data.Bild,
    Type: Data.Type,
    Frage: Data.Frage,
    Abschnitt: Text(Concatenate(Data.Abschnitt,"new"))
    }))

     

  • Anna123456 Profile Picture
    30 on at

    Thank you! It almost works ....

    I want it as new items. 

     

    Problem: For this part I get an error: 

    Abschnitt: Text(Concatenate(stepThrough.Abschnitt, "new")

     I get the error: Cannot use a non-record value in this context.

     

    It works for: 

    Abschnitt: stepThrough.Abschnitt

    But i need to store it with a new "Abschnitt" - Value. 

    Can you help me to solve the final problem? 

  • NandiniBhagya20 Profile Picture
    4,667 Super User 2024 Season 1 on at

    Hi @Anna123456 ,
    Is "stepThrough" a control name?
    What type of control is it - text input, dropdown, etc? If it is dropdown can you share Items property of it.
    What type of column is "Abschnitt" (single line of text, choice, perosn, yes/no, etc)? 

     

  • TheRobRush Profile Picture
    11,128 Moderator on at

    see my addition below, my original formula had a typo

  • Anna123456 Profile Picture
    30 on at

    It is a name for the iteration (see answer from TheRobRush)

    Patch(Fragen,
    	ForAll(Gallery2_5.AllItems As stepThrough,
    		{Bild:stepThrough.Bild,
    		Type:stepThrough.Type,
    		Frage:stepThrough.Frage,
    		Abschnitt: Text(Concatenate(stepThrough.Abschnitt, "new")}
    		)
    	)

     

  • TheRobRush Profile Picture
    11,128 Moderator on at
    Patch(Fragen,
    	ForAll(Gallery2_5.AllItems As stepThrough,
    		{Bild:stepThrough.Bild,
    		Type:stepThrough.Type,
    		Frage:stepThrough.Frage,
    		Abschnitt: Text(Concatenate(stepThrough.Abschnitt, "new"))}
    		)
    	)
  • TheRobRush Profile Picture
    11,128 Moderator on at

    Yah my original answer def had a typo

  • Anna123456 Profile Picture
    30 on at

    I think I understand my own problem, but I do not have a solution for it: 

     

    - I have 2 tables (fragen, abschnitte). 

    - Table "fragen" has a lookup for the column "abschnitt" of the table "abschnitte". 

    - I want to duplicate all items from "abschnitte" with the connected items from "fragen"

    -> I can duplicate an item from "abschnitte" with your code (thank you again!). With a new value in the column "abschnitt". 

    -> Now I want to duplicate all the items from "fragen" connected to the duplicated item from "abschnitte". BUT i need to store the new items from "fragen" with the new value of "abschnitt". And power apps always says that i can not use a non-record-value .... 

    Can you help me? 

    Duplication of "abschnitte" (works): 

    Set(varoldabschnitt, Gallery2_4.Selected.Abschnitt);
    Set(varnewabschnitt, Text(Concatenate(Gallery2_4.Selected.Abschnitt,Text(varnummerrand))));
    Set(varnummerrand, Rand());
    
    Patch(Abschnitte, Defaults(Abschnitte),
    {Abschnitt: varnewabschnitt,
    AbschnittNr: Text(Last(Filter(Sort(Abschnitte, Value(AbschnittNr)), Checkliste.Checkliste = Gallery2_4.Selected.Checkliste.Checkliste)).AbschnittNr) + 1,
    TabName:Gallery2_4.Selected.TabName, 
    Checkliste: Gallery2_4.Selected.Checkliste,
    Beschreibung:Gallery2_4.Selected.Beschreibung, 
    'Beschreibung immer sichtbar':Gallery2_4.Selected.'Beschreibung immer sichtbar'}
    );

     

    Duplication of "fragen" items connected to the old "abschnitt" from "abschnitte" (not working): 

    Patch(Fragen,
    	ForAll(Filter(Fragen, varoldabschnitt = Abschnitt.Abschnitt && Checkliste.Checkliste = Gallery2_3.Selected.Checkliste) As stepThrough,
    		{Bild:stepThrough.Bild,
    		Type:stepThrough.Type,
     Frage:stepThrough.Frage,
     Abschnitt: varnewabschnitt
    	}))

     

    The error: Invalid argument type (table). need a record value. 

  • TheRobRush Profile Picture
    11,128 Moderator on at

    can you hover over each over each word of the current formula and see if you can figure out which part of it is throwing the table/record error, then tell me what that part is,  what its value is (put it in a label maybe?) how its made etc, need a little more info because structurally the formula is written correctly

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 Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 352 Super User 2026 Season 2

#2
M Bilal Khan Profile Picture

M Bilal Khan 323

#3
Mohsin Ali Profile Picture

Mohsin Ali 226

Last 30 days Overall leaderboard