Querying all Marketing Lists associated To An Campaign In Microsoft CRM With C#

Microsoft CRM Jan 19, 2017

As I said in the other article, there are some exceptions from the usual many-to-many architecture – one of those exceptions are querying all marketing lists associated to an campaign In Microsoft CRM.

In this case you have to join with the CampaignItem table and check if the Logical Name of the entites matches.

If so, you will retrieve a full list of marketing lists.

EntityReference campaignref = campaign.ToEntityReference();

var lists = (from r in dataContext.CreateQuery<List>()
join s in dataContext.CreateQuery<CampaignItem>() on r.ListId equals s.EntityId
where s.EntityType == List.EntityLogicalName && s.CampaignId == campaignref
select r.ListId);

From this point on you can work with the marketing lists, retrieve their members, add new members, remove members or copy a complete list.

Tags

Great! You've successfully subscribed.
Great! Next, complete checkout for full access.
Welcome back! You've successfully signed in.
Success! Your account is fully activated, you now have access to all content.