XrmMockup
XrmMockup copied to clipboard
Issues working with CampaignItem(Intersect Entity)
I have recently stumbled into issues working with the intersection entity called CampaignItem. This intersect entity is a bit different as it intersect between campaign and four different target entities (List, Campaign, Product, SalesLiterature) as documented here.
In my case, I need to get all MarketingsLists related to a Campaign.
Calling either context.LoadEnumeration(campaign, x => x.campaignitem)
or context.LoadEnumeration(campaign, new Relationship("campaignlist_association"))
result in a NullReferenceException
.
I had more success by fetching all CampaignItem entities by calling context.CampaignItemSet. However, the retrieved list of CampaignItems are not populated with the data necessary to work with it. The CampaignItem holds three attributes referencing the four target entities in the intersect entity, EntityType
, EntityId
, and EntityState
. The EntityId
and EntityState
is populated but the EntityType
is not populated. So I am unable to filter out the four different kind of target entities. This might also be the reason that LoadEnumeration
returns a NullReferenceException
There might exist additional intersect entities with the same problem such as: