cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
MrNappa
Level: Powered On

Editor started giving formula errors about type

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?

4 REPLIES 4
Community Support Team
Community Support Team

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,

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
MrNappa
Level: Powered On

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.

MrNappa
Level: Powered On

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
Level: Powered On

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 ) });

 

 

 

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

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

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors (Last 30 Days)
Users online (5,187)