Skip to main content

Notifications

Power Apps - Power Apps Pro Dev & ISV
Unanswered

Issue: Power Apps Patch Function Not Saving Data from Collection

Like (1) ShareShare
ReportReport
Posted on 2 Oct 2024 08:13:03 by 6

 

I have an app in Power Apps that registers contract information with suppliers and stores it in an Excel sheet. The app includes a screen where the user can specify the number of suppliers (via an input box), and fields for each supplier are automatically generated.

I’m using the ClearCollect function to gather supplier information into a collection (LeverandorCollection), and then a ForAll function to iterate through the collection and save the data to an Excel table. However, while the form data is saved correctly, the data from the collection (supplier-specific information) is not being transferred or saved to the Excel sheet.

Here's the Patch function I'm currently using:

 
ForAll(
LeverandorCollection;
Patch(
Tabell2;
Defaults(Tabell2);
{
Leverandør: ThisRecord.LeverandorNavn;
'17 Organisasjonsummer': ThisRecord.OrgNummer;
'19 Kontaktperson leverandør (navn)': ThisRecord.KontaktNavn;
'20 Kontaktperson leverandør (epost)': ThisRecord.KontaktEpost;
'21 Fakturamerking/referanse': ThisRecord.FakturaReferanse
};
RegistrerFlereLeverandører.Updates
)
)

Despite this, only the form data is saved, and none of the supplier data from the collection gets through. What might be causing this, and how can I ensure the supplier data is saved correctly?

  • WarrenBelz Profile Picture
    WarrenBelz 144,479 on 05 Oct 2024 at 21:54:06
    Issue: Power Apps Patch Function Not Saving Data from Collection
    I will add a comment here as there is nothing fundamentally wrong with the code assuming those field names are valid. You can try this alternative
    ForAll(
       LeverandorCollection As _Data;
       Patch(
          Tabell2;
          Defaults(Tabell2);
          {
             Leverandør: _Data.LeverandorNavn;
             '17 Organisasjonsummer': _Data.OrgNummer;
             '19 Kontaktperson leverandør (navn)': _Data.KontaktNavn;
             '20 Kontaktperson leverandør (epost)': _Data.KontaktEpost;
             '21 Fakturamerking/referanse': _Data.FakturaReferanse
          },
          RegistrerFlereLeverandører.Updates
       )
    )
    but I think your underlying issue may be Excel itself, which is a terrible data source and really one of "last resort". Do you have access to SharePoint ? If so, create this in a List and your issues should go away.
  • scalca Profile Picture
    scalca 230 on 05 Oct 2024 at 08:56:58
    Issue: Power Apps Patch Function Not Saving Data from Collection
    do you get any error message ? 
    can you confirm connection to excel online sheet is working ? 
    can you check if you get any information from the excel sheet into the app just to be sure you are connected to the excel sheet ? 
  • SS-02100810-0 Profile Picture
    SS-02100810-0 6 on 03 Oct 2024 at 10:14:25
    Issue: Power Apps Patch Function Not Saving Data from Collection
    Hi, and thank you for your solution attempt. 

    When removing the .Updates part, nothing transfers to the excel table. When included atleast information from the form RegistrerFlereLeverandører gets transfered and stored. 

    A bit tricky this one. 

    Best regards,
    Simen

     
  • Nandit Profile Picture
    Nandit 1,545 on 02 Oct 2024 at 15:14:23
    Issue: Power Apps Patch Function Not Saving Data from Collection
     
    I don't think you need the RegistrerFlereLeverandører.Updates part in your code. 
    You just need the following to make it work:
    ForAll(
    LeverandorCollection;
    Patch(
    Tabell2;
    Defaults(Tabell2);
    {
    Leverandør: ThisRecord.LeverandorNavn;
    '17 Organisasjonsummer': ThisRecord.OrgNummer;
    '19 Kontaktperson leverandør (navn)': ThisRecord.KontaktNavn;
    '20 Kontaktperson leverandør (epost)': ThisRecord.KontaktEpost;
    '21 Fakturamerking/referanse': ThisRecord.FakturaReferanse
    }))
     
    Hope this helps. 
     
    Kind regards, 
    Nandit
     
    If this answers your query, please mark this response as the answer.
    If its helpful, please leave a like. Thanks!
     

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

November 2024 Newsletter…

November 2024 Community Newsletter…

Community Update Oct 28…

Power Platform Community Update…

Tuesday Tip #9 Get Recognized…

Welcome to a brand new series, Tuesday Tips…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 144,479

#2
RandyHayes Profile Picture

RandyHayes 76,308

#3
Pstork1 Profile Picture

Pstork1 64,350

Leaderboard
Loading complete