Hi,
I am first creating a collection (button saves and adds a new line)
Collect(LineItems, {ItemDescription:ItemDescriptionInput.Text, ItemQuantity:Value(QuantityDescriptionInput.Text),ItemDate:ItemDatePicker.SelectedDate});
UpdateContext({Defaults: false, DefaultDate: Today(), DefaultTextValue: "1"});
UpdateContext({Defaults: true, DefaultDate: Today(), DefaultTextValue: ""});
ClearCollect(DefaultRecord, "")
and then id like to patch it to the data source
Patch(PowerSalesLines, Defaults(LineItems), {Item_Description:ItemDescriptionInput.Text, Quantity:Value(QuantityDescriptionInput.Text),Date_Of_Usage:ItemDatePicker.SelectedDate })
but I keep getting this error
even if delete the date aspect of it. I really dont understand the error. But I also dont understand why I cant use the column names I chose for the collection but the textinput names.
Any help will be appreciated, thank you
Solved! Go to Solution.
You should use Defaults(PowerSalesLines), now you are trying to use the defaults as your collection (which includes ItemDate) for a new record in the datasource.
You should use Defaults(PowerSalesLines), now you are trying to use the defaults as your collection (which includes ItemDate) for a new record in the datasource.
Most people create collection to patch the whole collection. If you just want to patch few columns you can use ShowColumns in your defaults code
Patch(PowerSalesLines, ShowColumns(
Table(Defaults(PowerSalesLines)),
"Colum1",
"Colum2",
"Colum3"
), {Item_Description:ItemDescriptionInput.Text, Quantity:Value(QuantityDescriptionInput.Text),Date_Of_Usage:ItemDatePicker.SelectedDate })
Hi @IzabEwa ,
Please try the below codes if it helps.
Collect(LineItems, {ItemDescription:ItemDescriptionInput.Text, Quantity:Value(QuantityDescriptionInput.Text),Date_Of_Usage:ItemDatePicker.SelectedDate});
UpdateContext({Defaults: false, DefaultDate: Today(), DefaultTextValue: "1"});
UpdateContext({Defaults: true, DefaultDate: Today(), DefaultTextValue: ""});
ClearCollect(DefaultRecord, "")
Patch(PowerSalesLines, Defaults(LineItems), {Item_Description:ItemDescriptionInput.Text, Quantity:Value(QuantityDescriptionInput.Text),Date_Of_Usage:ItemDatePicker.SelectedDate })
or
//Collect(LineItems, {ItemDescription:ItemDescriptionInput.Text, Quantity:Value(QuantityDescriptionInput.Text),Date_Of_Usage:ItemDatePicker.SelectedDate});
UpdateContext({Defaults: false, DefaultDate: Today(), DefaultTextValue: "1"});
UpdateContext({Defaults: true, DefaultDate: Today(), DefaultTextValue: ""});
ClearCollect(DefaultRecord, "")
Patch(PowerSalesLines, Defaults(PowerSalesLines), {Item_Description:ItemDescriptionInput.Text, Quantity:Value(QuantityDescriptionInput.Text),Date_Of_Usage:ItemDatePicker.SelectedDate })
Any specific reason your creating collection LineItems ?
With the given code if LineItems is not used anywhere else than you can comment it out and try the second code.
Please click Accept as solution 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 giving it Thumbs Up.
If this post was helpful or you need more help please consider giving Thumbs Up and Tag me in your reply I'll be happy to help. If this post helped you solve your issue please click Accept as solution and provide Thumbs Up. This will help others find it more readily.
It is because I need to collect few items and then patch them to the data source and I cant do it with a form
User | Count |
---|---|
258 | |
111 | |
95 | |
48 | |
41 |