cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Super User
Super User

Two Collections, One Will NOT Take a Patch()

Hello,

Going bananas here... time to reach out to the community!

Scenario: 

  • Collection 1: 
    • Instantiated with:
      • ClearCollect(col1,
            {
                item1: " ",
                item2: " "
                etc.
            }
        )
    • Patch Statement:
      • Patch(col1,
            First(col1),
                {
                    item2: checkbox.Text
                }
        )
    • Results: WORKS GREAT
      • ClearCollect(col1,
            {
                item1: " ",
                item2: "yes"
                etc.
            }
        )
  • Collection 2: 
    • Instantiated with:
      • ClearCollect(col2, 
                Filter(sharePointList, 
                    ID = gallery.Selected.ID
                )
        )
    • Verified 'col2' contains data (View/Collections/col2)
    • Patch Statement: Exactly the same as `col1` except `col2`
      • Patch(col2,
            First(col2),
                {
                    item2: checkbox_1.Text
                }
        )
    • Results: WILL NOT PATCH!!!
      • ClearCollect(col2,
            {
                item1: " ",
                item2: " "
                etc.
            }
        )

I cannot figure this out! I literally have two checkboxes side-by-side setup and one Patches without issue on OnCheck. The other just plain will not. 

For reference, the UnCheck property of each is set to:

Patch(col1, //col2 for Collection 2
    First(col1), //col2 for Collection 2
    {
        Item2: Blank()
    }
)

Does anyone see what I could possibly be missing here?!?!

1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

Re: Two Collections, One Will NOT Take a Patch()

@ericonlineis that field in SharePoint empty when you collect??

If so - I've run into that issue before - Patch will not work.

Try using UpdateIf instead. 

   

UpdateIf(col2, ID=First(col2).ID, {item2: checkbox_1.text})

 

However - just to be clear - your first "works" has checkbox.text and the other has checkbox_1.

Just making sure you're not going crazy over the wrong checkbox.

 

Hopefully this helps and you can enjoy the bananas.

_____________________________________________________________________________________
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

10 REPLIES 10
Super User
Super User

Re: Two Collections, One Will NOT Take a Patch()

OMGosh this is crazy.

If I change the `col2` Patch statement to...

Patch(col2,
    Defaults(col2),
        {
            item2: checkbox_1.Text
        }
)

...the `item2` Column is Patched correctly but (of course) into a new record!! 

What would prevent me from Patching INTO an existing record like that?

Super User
Super User

Re: Two Collections, One Will NOT Take a Patch()

@ericonlineis that field in SharePoint empty when you collect??

If so - I've run into that issue before - Patch will not work.

Try using UpdateIf instead. 

   

UpdateIf(col2, ID=First(col2).ID, {item2: checkbox_1.text})

 

However - just to be clear - your first "works" has checkbox.text and the other has checkbox_1.

Just making sure you're not going crazy over the wrong checkbox.

 

Hopefully this helps and you can enjoy the bananas.

_____________________________________________________________________________________
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

Super User
Super User

Re: Two Collections, One Will NOT Take a Patch()

@ericonlineyup...have a small pile of hair here on the floor from when I first ran into that one!

_____________________________________________________________________________________
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.
Super User
Super User

Re: Two Collections, One Will NOT Take a Patch()

@RandyHayes , Thanks for the sanity check! I've definitely made mistakes like that before. In this case there are indeed two checkboxes. I'm doing a side by side comparison to narrow down the issue (`checkbox` and `checkbox_1`)

image.png

RE: Is that field in SharePoint empty when you Collect?:

  • I'm collecting a previously saved form (partial complete). May or may not be empty.
  • In this case, this particular column IS empty. 

RE: UpdateIf():

  • Going to try this right now! Will report back

 

Super User
Super User

Re: Two Collections, One Will NOT Take a Patch()

@ericonline  ah yes, the old naming issue.

 

You may not have the Patch issue with the empty field.  I know I ran into that with a collection gathered from SharePoint and trying to patch.  In my particular case it was a numeric column that would not patch no matter how much I tried.  Turned out, because it was empty when I collected and Patch had an issue with it.  Only UpdateIf would work..

_____________________________________________________________________________________
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.
Super User
Super User

Re: Two Collections, One Will NOT Take a Patch()

Jimminy Crickets! WHY!?!?

I'm going to officially report this as a bug!

image.png

@wyotim , @timl , @KickingApps , et. al. , #PowerHomie in the house @RandyHayes !! 

Thank you Randy

Super User
Super User

Re: Two Collections, One Will NOT Take a Patch()

To just make things more bizarre..

I didn't change the OnUnCheck Property.

Its still set to...

Patch(col2,
First(col2),
    {
        Item2: Blank()
    }
)

... and guess what... yeah... it WORKS!!

So I changed the OnCheck Property BACK TO...

Patch(col2,
First(col2),
    {
        Item2: checkbox_1.Text
    }
)

...and guess what...AGAIN...yeah... it WORKS NOW!!

I wonder if its because of the checkbox_1 Default Property. It is set to...

If(
    And(
        varPartialForm,
        ThisItem.ID = 2,
        First(col2).Item2 = "Yes"
    ),
    true,
    false
)

It almost wants to be a circular reference, but it can't make up its mind?

Either way, Boom! thank you

Super User
Super User

Re: Two Collections, One Will NOT Take a Patch()

@ericonline  I have to say - I have seen many times odd things like that.  For example, where I have to re-type in the exact same name in a formula to get things to work - I can see a red error, go in and re-type the exact same thing it is complaining about and it goes away.  Other times where everything goes nuts and I have to save, close out, and re-open and it all is normal again.  Those would have to be the most frustrating aspects of PowerApps for me.

Perhaps in time....

_____________________________________________________________________________________
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.
Super User
Super User

Re: Two Collections, One Will NOT Take a Patch()

Word.

And in the same breath, I've gone waaaaay down a rabbit hole and messed up my app big time and been able to CTRL+Z 112 times (I counted!) to get back to the last known good state of the session!! In a web app!
Love/Hate (mostly love) HA!
(But I hear you.. when it is hate, it sucks for awhile)

Helpful resources

Announcements
Better Together’ Contest Finalists Announced!

'Better Together’ Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

thirdimage

Power Apps Community User Group Member Badge

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

sixthImage

Join THE global Microsoft Power Platform event series

Attend for two days of expert-led learning and innovation on topics like AI and Analytics, powered by Dynamic Communities

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

thirdimage

Microsoft Business Applications Virtual Launch

Join us for the Microsoft Business Applications Virtual Launch Event on Thursday, April 2, 2020, at 8:00 AM PST.

thirdimage

Community Summit North America

Innovate, Collaborate, Grow - The top training and networking event across the globe for Microsoft Business Applications

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