cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Goerami
Regular Visitor

Save collection to Dataverse Table saves null

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

 

2 ACCEPTED SOLUTIONS

Accepted Solutions
RandyHayes
Super User
Super User

@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.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

RandyHayes
Super User
Super User

@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.

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

12 REPLIES 12
RandyHayes
Super User
Super User

@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.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!
Goerami
Regular Visitor

@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
Super User
Super User

@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?

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!
Goerami
Regular Visitor

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
Super User
Super User

@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.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!
Goerami
Regular Visitor

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
Super User
Super User

@Goerami 

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

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

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

}

)

RandyHayes
Super User
Super User

@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.

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Helpful resources

Announcements
Ignite 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Super User 2 - 2022 Congratulations

Welcome Super Users

The Super User program for 2022 - Season 2 has kicked off!

September Events 2022

Check out all of these events

Attend in person or online, there are incredible conferences and events happening all throughout the month of September.

Users online (2,183)