SelectionFacroty not working

Vote:
 

I have a page which has IList<Fruit> property in CMS. My fruit class has Benefit property. User can add Benefits from the same page in different tabs and those saved benefits are displayed in dropdown of the page. So, I used ISelectionFactory with SelectMany and tried to retrieve the saved benefits to dropdown. But metadata.FindOwnerContent() is giving null in GetSelections method of ISelectionFactory. This does not happen when I use Benefit property directly on the page. I need to identify page, to retrieve the saved benefits so that I can assign one of them to fruit.

In short,

Page has Ilist<fruit> and blocks of benefits.
Fruit class has Benefit property.

I want to map fruits with benefits and benefits itself is created in this page as block type. I could not find page reference or content link  id to retrieve benefits in this case.

#202270
Edited, Mar 21, 2019 12:03
Vote:
 

Can you show us some code?

#202272
Mar 21, 2019 12:13
Vote:
 

As I understook the you are needing to get owner content (page or block) from Selection Factory for Benefit propery when this property belongs to IList<Fruit> property.

I hope this code will help in your situation

metadata.Parent.FindOwnerContent()
#202758
Mar 30, 2019 12:47
Vote:
 

Hi,

As far as I'm aware, you can't get the owner content from a selection factory (or an attribute) inside an IList<T> property (I've tried various methods). By the looks of it there will be a fix in Epi 12 though I realise that's probably not much consolation right now:

https://world.episerver.com/forum/developer-forum/-Episerver-75-CMS/Thread-Container/2016/1/current-content-for-propertylist-item-selection-factory/

#202816
Apr 01, 2019 19:24
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.