Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Building Power Apps
Unanswered

Editor started giving formula errors about type

(0) ShareShare
ReportReport
Posted on by 241

So I'm working on this app. After finishing up 2 days ago, I intended to continue working on it yesterday. But... the editor suddenly handed me all kinds of error messages. Like "Incompatible type. We can't evaluate your formula because the values being compared in the formula aren't the same type."

Even stranger:

  • when I left it, everything was working. Nobody worked on it in the meantime.
  • if I 'F5/preview' the app in the browser from the editor screen, the parts that indicate errors don't work
  • but I published the app and 'play'ed it in the browser, and everything works correctly (including the parts that rely on formulas that now give editor errors)

But just as sudden as it appeared, at the end of the day the problem seemed to have resolved itself. Which would be a good thing, except... the problem returned just now, so I can still not continue working on the app.

 

My suspicion is that somehow the editor is starting to get confused about the type of items stored in a local collection compared to a remote datasource.

 

To indicate the outline of my app architecture: I'm creating a few local collections of entities that the user has to work on (this is because the app has a partial offline requirement). So I'm doing things like:

(OnSelect of a button after user makes a selection):
// Gather required data locally
// 'currentElements' will be a collection of items that were loaded from the CDS data source entity 'Elements'Collect( currentElements, Filter( [@Elements], <filter> );

(Later in the app, I display these items in a gallery with a filter)
[Gallery.Items =] Filter( currentElements, FilterField='FilterField( Elements )'.Yes )

(In another place, when attempting to save)
If( Connection.Connected,
Patch( Elements, elem, { Action: 1 } );
,
Collect( savebuffer, elem );
);

The highlighted parts are now problematic according to the editor.  The first one says 'incompatible type' and the second one  'Expecting a OptionSetValue value, but of a different schema.'

 

I'm at a loss how to solve it. I already tried:

  • Clearing browser cache, restarting the browser
  • Restore a previous save
  • Re-adding a data source that throws errors

Ideas? Could this be a bug?

  • MrNappa Profile Picture
    241 on at
    Re: Editor started giving formula errors about type

    In the end, I never identified the source to this problem. I still suspect the automatic type detection going buggy somewhere, but I can't be sure.

     

    I've worked around it by creating a 'local representation' of the data.

    For example, when retrieving data:

     

    // example
    ForAll( Filter( Rooms, <condition> ), Collect( localRooms, { Name: Name, Special: IsSpecial='IsSpecial (Rooms)'.Yes, ProjectId: ParentProject.Project, Date: ProjectDate, // <... etc ...> } ); );

    And when patching:

     

    // example
    Patch( Rooms, LookUp( Rooms, Room=editRoom.RoomId ), { Textfield: "Update",
    IsSpecial: If( Special, 'IsSpecial (Rooms)'.Yes, 'IsSpecial (Rooms)'.No ) });

     

     

     

  • MrNappa Profile Picture
    241 on at
    Re: Editor started giving formula errors about type

    It really seems as though the editor doesn't seem to understand anymore that the local collection is storing items of the type indicated by the data source. Somehow that connection is 'lost'. This is also the case for other collections in my app.

  • MrNappa Profile Picture
    241 on at
    Re: Editor started giving formula errors about type

    Hi Phoebe, thanks for your reply.

     


    @v-yutliu-msft wrote:

    Hi @MrNappa ,

    Do you mean that you have error message on these two formulas ?

    Filter( currentElements, FilterField='FilterField( Elements )'.Yes )
    Patch( Elements, elem, { Action: 1 } )

    Yes, and other places where I'm trying to work with that data too.

     


    @v-yutliu-msft wrote:

    What's more, the right syntax of Patch should be:

    Patch(Elements),Defaults(Elements),{....});
    
    Patch(Elements),the item that you want to modify,{....})

    Thanks, I'll run through my Patch code again, I could have made some mistakes. 

    Are you saying that 'Patch( Elements, elem, { Action: 1 } )' will not work if 'elem' was taken from the local collection, even though it was loaded from the 'Elements' data source in the first place?

     


    @v-yutliu-msft wrote:

    1)what is your data source?


    It's a Common Data Service data source for an entity in the current environment.

     


    @v-yutliu-msft wrote:

    2)what is your entity name, currentElements or Elements?


    The entity name is Elements. 'currentElements' is a Collection of the subset of Elements that the user is working with locally. It's loaded earlier from the data source like 'ClearCollect( currentElements, Filter( [@Elements], ParentRoom.Room=Room )'

     


    @v-yutliu-msft wrote:

    3)the data type of FilterField and Action?


    The filter field is a 'boolean' field (or rather the CRM equivalent a 'Two options' type -- that's why the error message is complaining about an incompatible OptionSetValue).  Action is a 'Whole Number' field.

  • v-yutliu-msft Profile Picture
    on at
    Re: Editor started giving formula errors about type

    Hi @MrNappa ,

    Do you mean that you have error message on these two formulas ?

    Filter( currentElements, FilterField='FilterField( Elements )'.Yes )
    Patch( Elements, elem, { Action: 1 } )

     Could you tell me

    1)what is your data source?

    2)what is your entity name, currentElements or Elements?

    3)the data type of FilterField and Action?

     

    What's more, the right syntax of Patch should be:

    Patch(Elements),Defaults(Elements),{....});
    
    Patch(Elements),the item that you want to modify,{....})

     

    Best regards,

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,660 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 66,004 Most Valuable Professional

Leaderboard