cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
IzabEwa
Helper IV
Helper IV

Patch error - column does not exsist

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

IzabEwa_0-1631022185640.png

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 

1 ACCEPTED SOLUTION

Accepted Solutions
shoog
Dual Super User
Dual Super User

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.

View solution in original post

4 REPLIES 4
shoog
Dual Super User
Dual Super User

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.

zmansuri
Super User
Super User

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 })

PG_WorXz10
Community Champion
Community Champion

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

 

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (2,732)