cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Jasmin_Sch
Helper IV
Helper IV

Patch all items of collection

Hi!

I got a gallery, with a collection as database.

 

To add rows to my gallery I got this function:

Collect(

    Tätigkeiten;

    ForAll(

        Sequence(2);

        {

            LineTitelTätigkeit: "Titel Tätigkeit";

            LineProjekttyp: "R&D";

            LinePrio: "Prio 1";

            LineStatus: "Offen"}))

 

This works.

 

Beside that I got an icon in every row to patch it.

Patch(

    Tätigkeiten;ThisItem;

        {

        LineTitelTätigkeit: 'Input Titel Tätigkeit'.Text;

        LineProjekttyp: "R&D";

            LinePrio: 'Input Prio'.Selected.Value;

            LineStatus: 'Input Status'.Selected.Value}

)

 

My question now: Is it possible to place this icon OUTSIDE of the gallery and make it patch ALL items in that gallery. Like it is having the same effect but I don’t have to select it for every row?

 

Thank you very much!

1 ACCEPTED SOLUTION

Accepted Solutions

I just found a work around. 
I set the patch function individual on the on change property of every item and it had the same effect

Thank you!

View solution in original post

7 REPLIES 7
connorwigg
Frequent Visitor

You should be able to do this with a ForAll() So a quick example would be

 

ForAll(CollectionName,

Patch(

    Tätigkeiten;ThisItem;

        {

        LineTitelTätigkeit: 'Input Titel Tätigkeit'.Text;

        LineProjekttyp: "R&D";

            LinePrio: 'Input Prio'.Selected.Value;

            LineStatus: 'Input Status'.Selected.Value}

))

I already tried this and it is showing me errors. I think it’s because of the „ThisItem“. The button should be not inside the gallery

name of collection: Tätigkeiten

Name of gallery: Gallery 1

RandyHayes
Super User
Super User

@Jasmin_Sch 

Please consider changing your Formula to the following:

Patch(Tätigkeiten;
    ForAll(Gallery1.AllItems As _item;
        {
           ID: _item.ID;
           LineTitelTätigkeit: _item.'Input Titel Tätigkeit'.Text;
           LineProjekttyp: "R&D";
           LinePrio: _item.'Input Prio'.Selected.Value;
           LineStatus: _item.'Input Status'.Selected.Value}
        )
    )
)

ForAll returns a table.  Use the output of it for the Patch - don't just waste the output by thinking that ForAll is a For/Loop...it's not.

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

@RandyHayes Thank your for your help

it is still not working. I don’t fully understand the ID part in the function. I don’t mention ID or LineID in my clear collect function. And if I insert it like you wrote it shows me errors like invalid name,not found,invalid argument table expected record. So I tried the function without ID but still nothing happens and an error says : datasource in function is invalid.

 

 

RandyHayes
Super User
Super User

@Jasmin_Sch 

What is the Items property of your Gallery?  It should include the record ID in it (always if possible).

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!
Jasmin_Sch
Helper IV
Helper IV

@RandyHayes thank you!

 

To create a collection for my repeating table

 

NewForm('Form Neu');;

ClearCollect(

    Tätigkeiten;ForAll(Sequence(10);

    {

        LineTitelTätigkeit: "Titel Tätigkeit";

        LineProjekttyp: "R&D";

        LinePrio: "Prio 1";

        LineStatus: "Offen";

        LineWunschressource: glbEmptyPerson;

        LineAbteilungWunschressource: "";

        LineAbteilung: "";

        LineGJ21Q1APV:"0";LineGJ21Q2APV:"0";

        LineGJ21Q3APV: "0";

        LineGJ21Q4APV: "0";

        LineGJ22Q1APV: "0";

        LineGJ22Q2APV: "0";

        LineGJ22Q3APV: "0";

        LineGJ22Q4APV: "0";

        LineGJ23Q1APV: "0";

        LineGJ23Q2APV: "0";

        LineGJ23Q3APV: "0";

        LineGJ23Q4APV: "0";

        LineGJ24Q1APV: "0";

        LineGJ24Q2APV: "0";

        LineGJ24Q3APV: "0";

        LineGJ24Q4APV: "0";

        LineGJ25Q1APV: "0";

        LineGJ25Q2APV: "0";

        LineGJ25Q3APV: "0";

        LineGJ25Q4APV: "0";

        LineGJ26Q1APV: "0";

        LineGJ26Q2APV: "0";

        LineGJ26Q3APV: "0";

        LineGJ26Q4APV: "0"     

                

    }

))

Gallery (Items Property: Tätigkeiten) is inside a container if this is worth mentioning.

I just found a work around. 
I set the patch function individual on the on change property of every item and it had the same effect

Thank you!

View solution in original post

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (1,602)