web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Suggested Answer

Get members of a marketing campaign

(0) ShareShare
ReportReport
Posted on by 55

Hi,

I need to get the accounts linked to a marketing campaign through plugin ,but i dont get any result (empty entitycollection)

code is below : 

  QueryExpression queryContrat = new QueryExpression();
                    queryContrat.EntityName = "account";
                    queryContrat.NoLock = true;
                    queryContrat.ColumnSet = new ColumnSet(true);


                    var linkListAccount = new LinkEntity("account", "listmember", "accountid", "entityid", JoinOperator.LeftOuter);
                    linkListAccount.EntityAlias = "member";
                    linkListAccount.Columns = new ColumnSet(true);
              

                    var linkListmember = new LinkEntity("listmember", "list", "listmemberid", "listid", JoinOperator.LeftOuter);
                    linkListmember.EntityAlias = "listmember";
                    linkListmember.Columns = new ColumnSet(true);

                   

                    var linkListcamapgne = new LinkEntity("list", "campaignitem", "listid", "entityid", JoinOperator.Inner);
                    linkListcamapgne.EntityAlias = "list";
                    linkListcamapgne.Columns = new ColumnSet(true);
                  

                    var linkcampagnitem = new LinkEntity("campaignitem", "campaign", "entityid", "campaignid", JoinOperator.Inner);
                    linkcampagnitem.EntityAlias = "cmitem";
                    linkcampagnitem.Columns = new ColumnSet(true);
                    linkcampagnitem.LinkCriteria.AddCondition("codename", ConditionOperator.Equal, code);

                    

                    linkListcamapgne.LinkEntities.Add(linkcampagnitem);
                    linkListmember.LinkEntities.Add(linkListcamapgne);
                    linkListAccount.LinkEntities.Add(linkListmember);
                    queryContrat.LinkEntities.Add(linkListAccount);


                    try
                    {
                        EntityCollection contrats = service.RetrieveMultiple(queryContrat);
                        if (contrats.Entities != null && contrats.Entities.Count > 0)
                        {
                            LogWebService.Log(ref _log, String.Format("Sortie de la fonction {0}", MethodBase.GetCurrentMethod()), LogWebService.LogLevel.Info);
                         return contrats;
                        }
                        else
                        {
                            LogWebService.Log(ref _log, String.Format("Sortie de la fonction {0}", MethodBase.GetCurrentMethod()), LogWebService.LogLevel.Info);
                            LogWebService.Log(ref _log, "CONTRAT_COLLECTION NULL", LogWebService.LogLevel.Info);
                            return null;
                        }

Thanks ,

I have the same question (0)
  • Suggested answer
    Pradeep Rai Profile Picture
    5,489 Moderator on at

    Hi,

    Please check below link:

     

    Thanks

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Hamza H Profile Picture

Hamza H 142 Super User 2026 Season 1

#2
Nagaraju_Matta Profile Picture

Nagaraju_Matta 128

#3
ManoVerse Profile Picture

ManoVerse 127 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans