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

Code failure

(1) ShareShare
ReportReport
Posted on by 4

 

 

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)
  • Power Platform 1919 Profile Picture
    2,079 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?
  • HG-14011109-0 Profile Picture
    4 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.
  • WarrenBelz Profile Picture
    153,495 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
    4 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
    153,495 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
    4 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)
     
  • Suggested answer
    WarrenBelz Profile Picture
    153,495 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  

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
Kalathiya Profile Picture

Kalathiya 401

#2
WarrenBelz Profile Picture

WarrenBelz 334 Most Valuable Professional

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 325 Super User 2025 Season 2

Last 30 days Overall leaderboard