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:
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:
Ideas? Could this be a bug?
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 ) });
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.
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.
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,
WarrenBelz
146,660
Most Valuable Professional
RandyHayes
76,287
Super User 2024 Season 1
Pstork1
66,004
Most Valuable Professional