web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Incompatible type erro...
Power Apps
Answered

Incompatible type error when using the SET() and PATCH() function together.

(0) ShareShare
ReportReport
Posted on by 5

I have this strange behavior inside the TEAMS Power Apps editor that I cannot understand. I have the following simple setup (with code directly from Microsoft). I basically want to set a global variable with SET() and then I would like to change some data in the global variable using SET() and PATCH() together. When I first add the object (a button) and enter the code, no issues. It works fine. But when I restart the app, the PATCH() function shows an error (Incompatible type). 

 

I have a button with ONSELECT:

 

 

 

Set( Person, { Name: "Milton", Address: "1 Main St" } )

 

 

  

I have another button with ONSELECT:

 

 

 

Set( Person, Patch( Person, {Address: "2 Main St" } ) )

 

 

 

As said, it works fine at start, but if I restart the app both buttons show an error. "Incompatible type". The code elements are taken from Microsoft own examples (SET FUNCTION). 

Categories:
I have the same question (0)
  • WarrenBelz Profile Picture
    155,242 Most Valuable Professional on at

    Hi @TripleEE ,

    I believe it is because you firstly set the Variable to a Record structure, then are typing to add a record to it, which would create a Table (therefore incompatible type). If you are trying to create a Table structure, a Collection is a far easier option. If you are simply replacing the value with another Record, you do not need Patch.

     

    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.

    MVP (Business Applications)   Visit my blog Practical Power Apps

  • Triplee23 Profile Picture
    5 on at

    I am sure you are correct. Yes, in the first SET() I am creating a record. I do admit that my example code above is simpler than the one I am actually trying to implement. But the symptoms are the same. It works in the beginning but when I restart the app I get the error.

     

    My reason for using PATCH() is that I have far many more columns in my record. And I only want to update some of them, therefore the PATCH(). The PATCH allows me to only update specific columns of the record. If I would run the SET() without PATCH(), I would have to define ALL columns in the record. Correct? 

     

    You are probably correct, I should. go for.a collection instead. All in all, I just want a global variable with multiple values in it that I can update individually. 

    But why do you think MS use these specific examples if they don't work?

  • Verified answer
    WarrenBelz Profile Picture
    155,242 Most Valuable Professional on at

    Hi @TripleEE ,

    This seems to work if you set the Variable as a Table in the beginning

    With(
     {_Person: Person},
     Set(
     Person,
     Ungroup(
     Table(
     {Data: Table({Address: "2 Main St"})},
     {Data: _Person}
     ),
     Data
     )
     )
    )

    first one would need at least two rows

    Set(
     Person,
     Table(
     {
     Name: "",
     Address: ""
     },
     {
     Name: "Milton",
     Address: "1 Main St"
     }
     )
    )

    To be honest, I would be using a Collection - that is what they are designed to hold (Tables)

     

    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.

    MVP (Business Applications)   Visit my blog Practical Power Apps

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Vish WR Profile Picture

Vish WR 914

#2
11manish Profile Picture

11manish 627

#3
Valantis Profile Picture

Valantis 598

Last 30 days Overall leaderboard