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 / forall to update multi...
Power Apps
Unanswered

forall to update multiple rows sql tabel

(0) ShareShare
ReportReport
Posted on by 65

i have a problem with updating multiple rows in sql table

my app is set up so that when u search for a ordernumber you will first get one entry that you can click in on and then you will see all orders with the same ordernumber

the problem comes when i try to update the sql table

 

you have tthe option to close the order and when you do that it should close all orders with the same order number but 2 problems arise when i try this

first all columns except for the one that registre if the order is closed get updatet to be null.

 

second it only updates one row and not all rows with the same order number

my code is
If(varNewPol = true, ForAll(colEditRestordre, Patch('EXCEL.RestOrdrer', LookUp('EXCEL.RestOrdrer', OrdreNr = Label_NewPol_OrdreNr_Value.Text), {Lukket: 1})));

lukket being the name of the column that registre if it closed or not. im not using boolean values but 0 and 1

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

    HI @fmc2022 ,

    The issue is that you need to refer to the field in the Collection for the target record (not a Text control)

    If(
     varNewPol, 
     ForAll(
     colEditRestordre As aCol, 
     Patch(
     'EXCEL.RestOrdrer', 
     LookUp(
     'EXCEL.RestOrdrer', 
     OrdreNr = aCol.FieldNameHere
     ), 
     {Lukket: 1}
     )
     )
    );

     

    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.

    MVP (Business Applications)   Visit my blog Practical Power Apps

     

  • fmc2022 Profile Picture
    65 on at

    thanks for the response but unfortunately it didnt work and i still get null in every column when i try 
    If(
    varNewPol,
    ForAll(
    colEditRestordre As aCol,
    Patch(
    'EXCEL.RestOrdrer',
    LookUp(
    'EXCEL.RestOrdrer',
    OrdreNr = aCol.SalesOrder
    ),
    {Lukket: 1}
    )
    )
    );

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

    @fmc2022 ,

    This structure

    If(
     varNewPol,
     ForAll(
     colEditRestordre As aCol,
     Patch(
     'EXCEL.RestOrdrer',
     LookUp(
     'EXCEL.RestOrdrer',
     OrdreNr = aCol.SalesOrder
     ),
     {Lukket: 1}
     )
     )
    );

    will update the field Lukket to 1 in every record in 'EXCEL.RestOrdrer' where the field OrdreNr matches a record in SalesOrder in the field colEditRestordre. I assumed that is what you needed to do.

  • fmc2022 Profile Picture
    65 on at

    I trust you on that but for some reason it dosent work as intendet so im a bit lost as to why. I did however find some other mistakes. so i changed my onCheck property of the checkbox that controls if the order should be closed to set(varCloseOrder, true) and changed 

     

    varNewPol to varCloseOrder.
    Still i have no luck it only changes 1 record with the given ordernumber. 

    I did however find the reason for all the Null values and it was a giant brainfart on my part. 
    I have a IF statement for patching the given fields to the sql database, and wouldn't you know it was If(varNewPol = true, do this else do that, so I have commended the patch out for now.

    but still no luck with the structure, it only updates one record 

  • Verified answer
    fmc2022 Profile Picture
    65 on at

    I finally found the problem it was that with the ordernumber for some reason.
    but i replaced it with id and it went through 
    f(
    varCloseOrder,
    ForAll(
    colRestordre As aCol,
    Patch(
    'EXCEL.RestOrdrer',
    LookUp(
    'EXCEL.RestOrdrer',
    ID = aCol.ID
    ),
    {Lukket: 1}
    )
    )
    );

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 796 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 327 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard