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

Re: Any Patch Experts Here?

I tried that new code and it works well.
Much cleaner than my effort.


Never knew about Coalesce, but after Googling it, it appears to return the item which has data.

 

The only thing I am confused on is the last statement.

If(IsBlank(MyItem), Set(LastAddedItem, patchResult))

 

When patchResult is first called, does it hold a returned record value?

The other thing I noticed is that when I put msg into a label, the label did not show any text.

 

Thanks

Highlighted
Super User
Super User

Re: Any Patch Experts Here?

@sienna28 

Yes, Coalesce is a wonderful function that makes formulas so much cleaner.  You can read more about it in the function docs.

 

As for that last statement - yes, you are specifically doing an UpdateContext on the local variable called patchResult. Then you are assigning the return of the Patch function.  Patch will return the entire record that you Patch...so, in this case, patchResult will have the patched record.

 

As for the label...that should show what is in the msg context variable.  At the very least, since you don't specifically clear it, it should show the very last text you updated it to.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Highlighted
Helper V
Helper V

Re: Any Patch Experts Here?

Ok I think I get it - the last statement is where you are looking for the record so that you can get the last added id which is used at the start of the procedure.

 

Yes I have msg as the text value of the label, but it does not seem to show the text from the code. 

It did with my code, but in this case it is not showing.

Perhaps I can delete the label and try with another one.

Highlighted
Super User
Super User

Re: Any Patch Experts Here?

@sienna28 

The "baked in" logic in the formula is that - if there is a DataTableID, then we use that, if not, then we use the LastAddedItem.ID, if not then myItem will be blank and therefore we will create (defaults) a new record with Patch.

So, based on that, if myItem is blank, then we know we just added a record and therefore we should set the LastAddedItem to the just added record in patchResult.

This is totally based on the fact that you call this "LastAddedItem".  If we wanted the last updated item, then we would not have the If(IsBlank(MyItem), Set... part there, we would just simply Set it.

 

Yeah, try something with that label. That seems a little strange as it should be showing something.  Also, perhaps try renaming the variable in your formula to lclMsg and then update your label to that.  (I, personally, use the lcl prefix to any Context variable so that I know, very quickly, that it is a context variable local to that screen only)

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.

View solution in original post

Highlighted
Helper V
Helper V

Re: Any Patch Experts Here?

Excellent.

 

I can move forward now and have learnt a great deal from your code.

 

Many thanks for all your help.

Helpful resources

Announcements
Check this Out

Helpful information

Featuring samples like Return to the Workplace and Emergency Response Applications

August 2020 Community Challenge: Can You Solve These?

August 2020 Community Challenge: Can You Solve These?

We're excited to announce our first cross-community 'Can You Solve These?' challenge!

secondImage

Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

secondImage

Super Users Coming in August

We are excited for the next Super User season.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (6,829)