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 / Patch multiple values ...
Power Apps
Unanswered

Patch multiple values on condition

(0) ShareShare
ReportReport
Posted on by 93
Hello,
 
what is the best solution for this?
 
I want to do a batch record to a table where there shall be in columns Employee (on the left, checkboxes), Block (combobox, more choices) and Date (datepicker)
 
It should write down like this:
Antonín Zeman 000-USW sváření 05.02.2025
Antonín Zeman 000-Vstřikování 05.02.2025
Antonín Zeman 000-Testování 05.02.2025
Jarda Venca 000-USW sváření 05.02.2025
Jarda Venca 000-Vstřikování 05.02.2025
Jarda Venca 000-Testování 05.02.2025
 
and in addition test if any of these records are already there.
 
Both employees and blocks form its own collection which is to be seen in the galleries.
 
 
Thank you for your ideas
JM
Categories:
I have the same question (0)
  • Michael E. Gernaey Profile Picture
    53,452 Super User 2025 Season 2 on at
    Hi,
     
    Can you clarify a few things
     
    1. Can you please list the columns and column types as well as for instance if choices are multi-select as all this makes a huge difference in patching, especially in batches.
     
    2. I am guessing you do mean separate records (as your table shows)
     
    3. I am unsure how to tell you if a record already exists unless a) you are already loading existing records and its an update, or if you need to do a "validation" that the record exists because it matches some criteria, which means you aren't going to be able to do this in batches. Not in a single call.
     
    4. Are the other 3 columns (not the person one) the other choices? And is it 3 single select choices?
  • Akah Mandela Profile Picture
    445 on at
    • Use collections for employees and blocks.
    • Create a ForAll loop for batch processing.
    • Check for duplicates before inserting using LookUp.
    • Use Patch for inserting new records.
    Step 1: Prepare Collections (If Not Already Created)
    // Example collection for employees
    ClearCollect(colEmployees, 
        {Name: "Antonín Zeman"}, 
        {Name: "Jarda Venca"}
    );
    // Example collection for blocks
    ClearCollect(colBlocks, 
        {BlockName: "000-USW sváření"}, 
        {BlockName: "000-VstÅ™ikování"}, 
        {BlockName: "000-Testování"}
    );
     

    Step 2: Batch Insert with Duplicate Check

    Assume:

    • colSelectedEmployees contains selected employees from the gallery (checkboxes).
    • colSelectedBlocks contains selected blocks from the combobox.
    • dpDatePicker.SelectedDate is the selected date from the date picker.
    • Target table: EmployeeBlockTable.
    ForAll(
        colSelectedEmployees,
        ForAll(
            colSelectedBlocks,
            If(
                IsBlank(
                    LookUp(
                        EmployeeBlockTable,
                        Employee = ThisRecord.Name &&
                        Block = BlockName &&
                        Date = dpDatePicker.SelectedDate
                    )
                ),
                Patch(
                    EmployeeBlockTable,
                    Defaults(EmployeeBlockTable),
                    {
                        Employee: ThisRecord.Name,
                        Block: BlockName,
                        Date: dpDatePicker.SelectedDate
                    }
                )
            )
        )
    );



    Hope this helps you out
  • JM-14081323-0 Profile Picture
    93 on at
    Hello and thanks for your interest.
     
    Yeah, the collections are already created. Everything you are assuming is right.
     
    This is how it looks now for me (not yet implemented update of the column Platnost (datepicker) if the record is found):
     
    ForAll(
        colDelnikhrom;
        ForAll(
            colBlokyhrom;
            If(
                IsBlank(
                    LookUp(
                        DelnikVNKN;
                        Delnik = ThisRecord.Delnik &&
                        VNKN = Seznam                     
                    )
                );
                Patch(
                    DelnikVNKN;
                    Defaults(DelnikVNKN);
                    {
                        Delnik: ThisRecord.Delnik;
                        VNKN: Seznam;
                        Platnost: DatePickerHrom.SelectedDate
                    }
                )
            )
        )
    )
     
     
     
    I am getting errors in Lookup part:
    These types cannot be compared: record, record
    These types cannot be compared: record, text
    and in Patch part:
    type of argument "crf13_delnik" is not expected type Record. Found type error.
     
    DelnikVNKN is the table in question. Delnik is lookup column into Delnik table where the name of the employee is column Jméno. VNKN is lookup column into the VNKN table where the name of the block is column Seznam. Platnost is dateformat column in DelnikVNKN table itself. Choices in combobox (blocks) are indeed multiselect allowed.
    In DelnikVNKN table there can already be a record which matches the combination of Delnik and VNKN. On this event I only want to update a date. I this combination is not there, then to set up a whole new record (Delnik, VNKN, Platnost).
     
    I will continue try to get it done somehow, if you can help me some more with the formulas, thank you in advance

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 739 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 268

Last 30 days Overall leaderboard