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 Apps
Suggested Answer

Code failure

(1) ShareShare
ReportReport
Posted on by 24

 

 

Hi. Trying to create a small app for ordering some products.

I have a list called "Ordre" with the columns OrdreID(text), Butikknavn(text), Bestiller(text), Produkt(text), Antall(number), Dato(date). 
And a list called "Produketer" with the columns Produkt(text), Spesifikasjoner(text), Bilde(image).

I have created a gallery that retrieves from Produkter. Here I insert a field called txtAntall which will retrieve the quantity they want to order.
In the header there are two fields called "Butikknavn" and "Bestiller". The button is inserted in the footer, and this will then retrieve data from txtAntall, 
"Butikknavn" and "Bestiller". Then send this data to the list Ordre. I have a code but it just fails. I have a Norwegian version. This code now fails at "," after 
"Ny bestilling. But I don't understand why.

 

 

ForAll(

    Filter(Galleri.AllItems; Value(txtAntall.Text) > 0) As CurrentItem;

    Patch(

        Ordre;

        Defaults(Ordre);

        {

            Tittel: "Ny bestilling",

            Butikknavn: CurrentItem.txtButikk.Text;

            Bestiller: CurrentItem.txtBestiller.Text;

            Produkt: CurrentItem.Tittel;

            Antall: Value(CurrentItem.txtAntall.Text)

        }

    )

)

 Notify("Bestillingen er sendt!", NotificationType.Success);;

Reset(txtButikknavn);;

Reset(txtBestiller)

power app.png

Your file is currently under scan for potential threats. Please wait while we review it for any viruses or malicious content.

I have the same question (0)
  • Suggested answer
    WarrenBelz Profile Picture
    154,496 Most Valuable Professional on at
    Two things here - firstly a comma is not valid as a line separator in your Regional syntax. Also (although this is not an error),  ForAll is not designed to be a loop, although it can act that way if it contains an action inside it. ForAll creates a Table, which can be Patched in one action to the data source and will run much faster than individual Patches for each record. If it contains the ID of each record, it will update the specific records, if not it will create new records (as in your case)
    Patch(
       Ordre;
       ForAll(
          Filter(
             Galleri.AllItems; 
             Value(txtAntall.Text) > 0
          ) As CurrentItem;
          {
             Tittel: "Ny bestilling";
             Butikknavn: CurrentItem.txtButikk.Text;
             Bestiller: CurrentItem.txtBestiller.Text;
             Produkt: CurrentItem.Tittel;
             Antall: Value(CurrentItem.txtAntall.Text)
          }
       )
    );;
    Notify(
       "Bestillingen er sendt!"; 
       NotificationType.Success
    );;
    Reset(txtButikknavn);;
    Reset(txtBestiller)
     
    Please ✅ Does this answer your question 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 answering Yes to Was this reply helpful? or give it a Like ♥
    Visit my blog
    Practical Power Apps    LinkedIn  
  • HG-14011109-0 Profile Picture
    24 on at
    If I change the code to this I just get further errors.
    Now if shows error from start to ) - before );;
     
    All the fields get an colourd frame in the app when I got in to the code.
    But not the button
     
    Patch(
       Ordre;
       ForAll(
          Filter(
             Galleri.AllItems;
             Value(txtAntall.Text) > 0
          ) As CurrentItem;
          {
             Tittel: "Ny bestilling";
             Butikknavn: CurrentItem.txtButikk.Text;
             Bestiller: CurrentItem.txtBestiller.Text;
             Produkt: CurrentItem.Tittel;
             Antall: Value(CurrentItem.txtAntall.Text)
          }
       )
    );;
     
    Notify(
       "Bestillingen er sendt!";
       NotificationType.Success
    );;
    Reset(txtButikk);;
    Reset(txtBestiller)
     
  • WarrenBelz Profile Picture
    154,496 Most Valuable Professional on at
    A quick follow-up to see if you received the answer you were looking for. Happy to assist further if not.
     
    Please ✅ Does this answer your question 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 answering Yes to Was this reply helpful? or give it a Like â™¥
    Visit my blog
    Practical Power Apps    LinkedIn   
  • HG-14011109-0 Profile Picture
    24 on at
     
    If you see my new post it did not work I an afraid.
    The post become an answer and not a respond to you I now see.
  • WarrenBelz Profile Picture
    154,496 Most Valuable Professional on at
    I cannot see any other posts from your profile. Also please do not start new posts on an unsolved issue - just makes everyone start again. If you respond with what is not working, you will generally find the issue will be solved.
  • HG-14011109-0 Profile Picture
    24 on at
    Hi. 
    I have not started an new post with an new problem. I have just replyed under my own post and it is higher up in the thread.
  • Power Platform 1919 Profile Picture
    2,205 Super User 2026 Season 1 on at
    Hi ,
    can you try this :
     
    ForAll(
        Filter(
            Galleri.AllItems;
            Value(txtAntall.Text) > 0
        );
        Patch(
            Ordre;
            Defaults(Ordre);
            {
                Tittel: "Ny bestilling";
                Butikknavn: txtButikk.Text;
                Bestiller: txtBestiller.Text;
                Produkt: ThisRecord.Tittel;
                Antall: Value(txtAntall.Text)
            }
        )
    );;
    
    Notify(
        "Bestillingen er sendt!";
        NotificationType.Success
    );;
    
    Reset(txtButikk);;
    Reset(txtBestiller);;
    
     
    Also, the approach provided by  is the best option. Using ForAll with Patch inserts records one at a time and can be slow, while combining Patch without ForAll (bulk pattern) results in more efficient, near–bulk inserts.

    Also, Can you share the exact error message you see when you hover over the error block in the formula, so we can help rectify it?
  • WarrenBelz Profile Picture
    154,496 Most Valuable Professional on at
    OK - I see that now -the threads seem to have reversed order again.
    There is nothing wrong with the structures that either @Power Platform 1919 or myself posted providing that the values you are posting match the field types they are being posted to. Both should work, however as we both pointed out, what I posted should run much faster. So the question really is what is the error message you are receiving ?
  • HG-14011109-0 Profile Picture
    24 on at
    Hi.
     
     
    I don't know where to start. As there are invalid arguments for Patch, invalid argument type (Table) expected Record value instead. AND name error, which I can't figure out.

    Attached here are the pictures of the tables I use and the tree/structure.
    Ordre.png
    Produkter.png
    tree.png
  • Power Platform 1919 Profile Picture
    2,205 Super User 2026 Season 1 on at
    HI , According to the screenshot shared, i am not seeing any controls named txtButikk, txtBestiller, Tittel , with in the gallery control tree view,.
     

    i think that is causing the error.
    and 
    txtBestiller is outside the gallery , so it doesnt work with currentitem.

    and also txtButikk should be txtButikknan (i think) which is outside the gallery.




    correct formula is : 
     
    Patch(
       Ordre;
       ForAll(
          Filter(
             Galleri.AllItems; 
             Value(txtAntall.Text) > 0
          ) As CurrentItem;
          {
             Tittel: "Ny bestilling";
             Butikknavn: txtButikknan.Text;
             Bestiller: txtBestiller.Text;
             Produkt: CurrentItem.Tittel;   // need to check this (not able to find in gallery tree)
             Antall: Value(CurrentItem.txtAntall.Text)
          }
       )
    );;
    Notify(
       "Bestillingen er sendt!"; 
       NotificationType.Success
    );;
    Reset(txtButikknavn);;
    Reset(txtBestiller)


     , what do you think? i might be wrong.
     

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 531 Most Valuable Professional

#2
Haque Profile Picture

Haque 261

#3
Kalathiya Profile Picture

Kalathiya 221 Super User 2026 Season 1

Last 30 days Overall leaderboard