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
Solved! Go to Solution.
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.
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.
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.
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 .
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?
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.
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.
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.
What is the formula you are using to put those two columns (and possibly others) into your collection?
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
}
)
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.
The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.
User | Count |
---|---|
182 | |
95 | |
66 | |
64 | |
60 |
User | Count |
---|---|
243 | |
163 | |
94 | |
82 | |
80 |