cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted

Patch modify or create new

Dear @PowerAddict  and other experts,

 

I am thankful so far for the wonderful learning I am having from you. I have made a patch to create a record, but I want to modify the function to either edit or create. Once press the button if it is a new record add it otherwise override it 

 

Patch('Cash Received',Defaults('Cash Received'),{Date:DataCardValue180_2.SelectedDate},{'Customer Name':DataCardValue181_2.Selected},{Amount:Value(DataCardValue182_2.Text)},{InvoiceNumber:DataCardValue179_2.Text});

 

Thank you in advance

Osmand

1 ACCEPTED SOLUTION

Accepted Solutions
Dual Super User
Dual Super User

Re: Patch modify or create new

Hey @OsmandFernando 

 

Can you share more details on the criteria to identify if this is a new record or an old record?

In a case, where you have a unique identifier and want to update based on it, you can use the below expression:

If(DataCardValue179_2.Text in 'Cash Received'.InvoiceNumber ,Patch('Cash Received',LookUp('Cash Received', InvoiceNumber = DataCardValue179_2.Text),{Date:DataCardValue180_2.SelectedDate,'Customer Name':DataCardValue181_2.Selected, Amount:Value(DataCardValue182_2.Text), InvoiceNumber:DataCardValue179_2.Text}),Patch('Cash Received',Defaults('Cash Received'),{Date:DataCardValue180_2.SelectedDate,'Customer Name':DataCardValue181_2.Selected,Amount:Value(DataCardValue182_2.Text), InvoiceNumber:DataCardValue179_2.Text}))

here, if the invoice number exists, this will update the record and if it does not then a new record will be created. Please share more details if this differs from what you expect it to be.

 

Hope this Helps!

 

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

View solution in original post

2 REPLIES 2
Dual Super User
Dual Super User

Re: Patch modify or create new

Hey @OsmandFernando 

 

Can you share more details on the criteria to identify if this is a new record or an old record?

In a case, where you have a unique identifier and want to update based on it, you can use the below expression:

If(DataCardValue179_2.Text in 'Cash Received'.InvoiceNumber ,Patch('Cash Received',LookUp('Cash Received', InvoiceNumber = DataCardValue179_2.Text),{Date:DataCardValue180_2.SelectedDate,'Customer Name':DataCardValue181_2.Selected, Amount:Value(DataCardValue182_2.Text), InvoiceNumber:DataCardValue179_2.Text}),Patch('Cash Received',Defaults('Cash Received'),{Date:DataCardValue180_2.SelectedDate,'Customer Name':DataCardValue181_2.Selected,Amount:Value(DataCardValue182_2.Text), InvoiceNumber:DataCardValue179_2.Text}))

here, if the invoice number exists, this will update the record and if it does not then a new record will be created. Please share more details if this differs from what you expect it to be.

 

Hope this Helps!

 

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

View solution in original post

Re: Patch modify or create new

@yashag2255  bro, i can not ask more than that. wonderful

 

Thank you so much

 

Osmand

Helpful resources

Announcements
thirdimage

Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

SecondImage

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Top Kudoed Authors (Last 30 Days)
Users online (3,832)