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 / Save collection to Dat...
Power Apps
Unanswered

Save collection to Dataverse Table saves null

(0) ShareShare
ReportReport
Posted on by 18

I'm trying to save a collection (called: artikelen) to a dataverse table (called: orderregels) by using the Patch function.

 

My collection has the following columns:

artikel

fabrikant

 

My Dataverse table has the following columns:

artikelnaam

fabri

And of course the default columns

 

I give a button the following formula:

 

ForAll( artikelen;
Patch('orderregels';

Defaults('orderregels');

{ artikelnaam: artikel ;
fabri: fabrikant
}
)
)

 

the problem is There is a new record created in the DataVerse table but the artikelnaam and fabri are empty (null)

I tried very many like artikelen(@artikel] but nothing seems to work. 

Please can anybody give me the solution?

 

thnx!

Erik

 

Categories:
I have the same question (0)
  • Verified answer
    RandyHayes Profile Picture
    76,297 Super User 2024 Season 1 on at

    @Goerami 

    First, your ForAll is backward!  ForAll is a function that returns a Table of records.  Using it like a ForLoop in the development world (although you can) will impact your performance and results.

    Please consider changing your Formula to the following:

    Patch('orderregels';
     ForAll( artikelen;
     Patch(Defaults('orderregels');
     { artikelnaam: artikel ;
     fabri: fabrikant
     }
     )
     )
    )

    You might also be able to avoid the Defaults if there are no specific defaults that need to be applied.

    Formula would then be:

    Patch('orderregels';
     ForAll( artikelen;
     { artikelnaam: artikel ;
     fabri: fabrikant
     }
     )
    )

    If you have conflicting column names for some reason (I don't see why in your formula, but just for Info), you can name your result table rather than use disambiguation syntax.  The formula would be:

    Patch('orderregels';
     ForAll( artikelen As _item;
     Patch(Defaults('orderregels');
     { artikelnaam: _item.artikel ;
     fabri: _item.fabrikant
     }
     )
     )
    )

     

    I hope this is helpful for you.

  • Goerami Profile Picture
    18 on at

    @RandyHayes 

    First of all many thanks for your answer. I'm new in working with PowerApps so I'm learning every day more about it.

    Unfortunately your solution isn't the solution for my problem. There is a new record in my Dataverse Table but without the columns fabri and artikelnaam are still getting NULL .

     

     

  • RandyHayes Profile Picture
    76,297 Super User 2024 Season 1 on at

    @Goerami 

    Okay...the formula is now correct.  There is something else at play here.

    What kind of columns are fabri and artikelnaam in your dataverse table?

    Also, are they the same type of columns in your collection...and does your collection actually have them in?

  • Goerami Profile Picture
    18 on at

    Hi @RandyHayes ,

    Fabri and artikelnaam are text columns

    artikel and fabrikant in the collection are text columns too (i think, because I don't know where I can check that). The fields in my canvas app are text format.

     

    I have attached a screenshot of my Dataverse table where you can see the artikelnaam and fabri column.

     

  • RandyHayes Profile Picture
    76,297 Super User 2024 Season 1 on at

    @Goerami 

    I would double check your collection then too and make sure there is data in it as you expect.

    You can look at the contents of it in your formula by clicking on the collection name and then expanding the data viewer at the bottom of the formula editor.

  • Goerami Profile Picture
    18 on at

    hi @RandyHayes 

    I checked it and there is something in it. But i can't see what .  I have made a gallery and connected the collection to it. In the gallery I can see everything I added to the collection.

  • RandyHayes Profile Picture
    76,297 Super User 2024 Season 1 on at

    @Goerami 

    What is the formula you are using to put those two columns (and possibly others) into your collection? 

  • Goerami Profile Picture
    18 on at

    This is the formula and attached the canvas app :

     

    Collect(artikelen;

    {

    artikel:txt_neworder2_artikel;

    fabrikant:txt_neworder2_fabrikant;

    type:txt_neworder2_type;

    maatl:txt_neworder2_maatl;

    maatb:txt_neworder2_maatb;

    aantal:txt_neworder2_aantal;

    prijs:txt_neworder2_prijs;

    korting:txt_neworder2_korting;

    gereserveerd:chkbox_neworder2_gereserveerd;

    gratis:chkbox_neworder2_gratis;

    opmerking:txt_neworder2_opmerking

    }

    )

  • Verified answer
    RandyHayes Profile Picture
    76,297 Super User 2024 Season 1 on at

    @Goerami 

    Yep...there is the issue.  You are assigning complete controls to the record, not the property of the control that you want.

    I noticed in your last screenshot that the formula editor was showing "Besteuringselement" for the data in those columns.  

     

    You need to reference the property of the control that you want.  So your formula will become:

    Collect(artikelen;

     {

      artikel:txt_neworder2_artikel.Text;

      fabrikant:txt_neworder2_fabrikant.Text;

      ...etc..

     

    Otherwise, you are trying to set the column to a complete control.  And then when you try to write that to your table...it has no idea what it is.

     

  • Goerami Profile Picture
    18 on at

    @RandyHayes 

    WOW! thnx! now I can see the items I added in the collection, but, now the formula to save the collection to the dataverse table gives an error. Powerapps say it expect a record and not a table :S 

     

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