I have a scenario where I ClearCollect data from a CDS entity so that I can use it locally within the app. On a given screen, I have a Gallery to view the collection records, a Display Form to see selected record details, and an Edit Form to input/modify child record data of a related entity. To drive the functionality, rather than using the Gallery.Selected identifier, I'm using a context variable defined as follows:
Gallery.OnSelect = UpdateContext({locCurrentItemRecord:ThisItem})
After setting up the screen and controls referencing Display Names (e.g. locCurrentItemRecord.Name, locCurrentItemRecord.Level, etc.) and getting the screen to function exactly as intended, I began to work elsewhere in the app. When I came back to this screen, I saw an "Invalid Argument Type" error at each use of the context variable. Specifically, the identified field name had the red underline and when you hover over it it says "This identifier isn't recognized". When I changed the Display Name to the Logical Name, the error clears and the screen continues to function as it did previously.
I am curious what is triggering this change in operation of the screen and the previously functioning expressions? My understanding is that there is mapping that occurs in the background that permits the use of Display Names. Is this not the case with collections? Should I proceed, when using collections, to simply reference the Logical Name the first time, so I don't have to go back and change this?
It may be worth noting that I'm supplementing the CDS data on the initial ClearCollect by using the AddColumns. Thanks in advance.