-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Description
Which Umbraco version are you using?
16.3.1
Bug summary
After upgrading from Umbraco 13.11.0 to Umbraco 16.3.1 the value from a member picker field cannot be pattern matched to a strongly typed (custom) member object.
Specifics
In Umbraco 13, we could rely on the fact that the following code worked flawlessly for our client solution:
if (certification.Profile is not Profile profile || certification.Candidate is not Candidate candidate) { return null; }
The "profile" and "candidate" fields are both links to items, the "profile" links to a different content item, while the "candidate" field is a member picker.
In Umbraco 13 this code would return an actual candidate if the field was filled in correctly. We could then use properties defined on the Candidate model (that was synced using the Models builder functionality).
Now that we've upgraded to Umbraco 16.3.1, this functionality sadly does not work anymore. The candidate value is empty (even though we use the same data).
Steps to reproduce
- Create a Umbraco 13 project with a document type that has a field of type "member picker" on it
- Create some items and link a member to it
- Make sure the models are synced locally to use them in your custom api endpoints
- Use the if statement with pattern matching to convert the value of the "member picker" field to the actual strongly typed model of the member type of your choice (ideally create a custom member type to match our implementation)
- You should see that the pattern matching succeeds, leading to the candidate variable containing a useful value instead of "null"
Repeat the above steps for a fresh Umbraco 16.3.1 instance and compare the results of step 5
Expected result / actual result
Expected result: you should be able to use pattern matching to convert an IPublishedContent value, coming from the member picker field, to a strongly typed (custom) member object in Umbraco 16
Actual result: performing the pattern match leads to the candidate variable being "null"