Skip to main content

Notifications

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 ,

  • Suggested answer
    Pradeep Rai Profile Picture
    Pradeep Rai 5,490 Super User 2024 Season 2 on at
    RE: Get members of a marketing campaign

    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

News and Announcements

Announcing Category Subscriptions!

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,359 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,370 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans