cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
OsmandFernando
Post Prodigy
Post Prodigy

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
yashag2255
Dual Super User II
Dual Super User II

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
yashag2255
Dual Super User II
Dual Super User II

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

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

 

Thank you so much

 

Osmand

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Power Apps June 2021

June Power Apps Community Call

Did you miss the call? Check out the recording here!

Top Solution Authors
Top Kudoed Authors
Users online (79,051)