When attaching a SelectOne or SelectMany attribute to a POCO object property being edited as part of a PropertyList property, the ExtendedMetadata object only contains the POCO object. The Model property is null, and it seems there's no way of getting the current content being edited, i.e. the current IContent object.
public IEnumerable GetSelections(ExtendedMetadata metadata)
var currentContent = metadata.FindOwnerContent(); // This is null
I briefly had an idea of getting the current content by parsing the URL, but since the URL is for the selection factory store, that doesn't help me much - that URL doesn't contain any information about the current content context.
Any bright ideas? :)
That is basically what is done in the FindOwnerContent method. I don't think it works for PropertyList
Thanks, Marija! I'm not sure that works, though?
It would normally, but when editing a PropertyList item (i.e. a POCO object) the selection factory REST store request simply includes the name of the selection factory type - there is no content context information.
That code sample could be replaced with the FindOwnerContent extension method, but regardless I still get null back. :/
Edit: Right, like Per said. :)
Old thread, I know! But... did you ever find a soloution for this? I'm running into the same problem :)
If you have latest version of Epi and it still doesn't, it sounds like it should be reported as a bug to Episerver support. I couldn't find a bug report, see this.
I got this answer from Episerver today 2018-06-19
"We're developing a story that will fix this issue. The story will be released in CMS UI 12 that requires some breaking changes."
I'm into the same problem. Is there any alternative solution to it?
OK, I managed to fix this.Solution would be available in CMS UI 11.36.2Stay tuned!
Available here: https://nuget.optimizely.com/package/?id=EPiServer.CMS.UI&v=12.0.2