Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

How to get Marketing List Members in plug-in

Posted on by Microsoft Employee

I want to get marketing list Account and contact member, But i can not find the member's entity.

2018_2D00_06_2D00_12_5F00_093957.png

*This post is locked for comments

  • Aric Levin Profile Picture
    Aric Levin 30,188 on at
    RE: How to get Marketing List Members in plug-in

    Andrew,

    Copied some old code that I had. Didn't check into too much detail, but it is working in some solution.

    Thanks for the catch, I will fix it in the solution.

    All the best.

  • a33ik Profile Picture
    a33ik 84,323 Most Valuable Professional on at
    RE: How to get Marketing List Members in plug-in

    Aric,

    The second Link makes no sense in this particular case. It's possible to filter based on intersect entity.

  • Suggested answer
    Aric Levin Profile Picture
    Aric Levin 30,188 on at
    RE: How to get Marketing List Members in plug-in

    You can use the following query expression to retrieve list members:

              QueryExpression query = new QueryExpression()

               {

                   EntityName = "contact",

                   ColumnSet = columns,

                   LinkEntities =

                   {

                      new LinkEntity()

                      {

                          LinkToEntityName = "listmember",

                          LinkToAttributeName = "entityid",

                          LinkFromAttributeName = "contactid",

                          LinkEntities =

                          {

                              new LinkEntity()

                              {

                                  LinkToEntityName = "list",

                                  LinkToAttributeName = "listid",

                                  LinkFromAttributeName = "listid",

                                  LinkCriteria =

                                  {

                                       Conditions =

                                       {

                                           new ConditionExpression("listid", ConditionOperator.Equal, listid)

                                       }

                                  }

                              }

                          }

                      }

                   }

               };

    If you are using a Dynamic List, you can use the following:

    Entity list = service.Retrieve("list", listId, new ColumnSet(true));

    listType = (bool)list.Attributes["type"];

    query = list.Contains("query") ? list.Attributes["query"].ToString() : string.Empty;

    FetchExpression fe = new FetchExpression(query);

    EntityCollection rc = service.RetrieveMultiple(fe);

    Hope this helps...

  • Suggested answer
    Adrian Begovich Profile Picture
    Adrian Begovich 21,009 Super User 2024 Season 2 on at
    RE: How to get Marketing List Members in plug-in

    Hi Evan li,

    Did you use QueryExpression with the LinkEntity property to properly assemble the query?

  • Verified answer
    a33ik Profile Picture
    a33ik 84,323 Most Valuable Professional on at
    RE: How to get Marketing List Members in plug-in

    Evan, I'm sorry for this. It seems that this code is related to v 4.0. Let me bring you another example - nishantrana.me/.../sample-code-to-retrieve-all-the-members-of-a-static-marketing-list-in-crm-2011

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to get Marketing List Members in plug-in

    Hi Andrew,

    Thank you for your help.

    In below code

    [Code]

    RetrieveMultipleRequest request = new RetrieveMultipleRequest { ReturnDynamicEntities = true, Query = query };

    RetrieveMultipleResponse response = (RetrieveMultipleResponse)crmService.Execute(request);

    retVar = (response.BusinessEntityCollection.BusinessEntities.Count > 0);

    [/Code]

    I can not find the attribute : RetrieveMultipleRequest.ReturnDynamicEntities  and RetrieveMultipleResponse.BusinessEntityCollection

    2018_2D00_06_2D00_12_5F00_105732.png

    2018_2D00_06_2D00_12_5F00_105732.png

  • Suggested answer
    Adrian Begovich Profile Picture
    Adrian Begovich 21,009 Super User 2024 Season 2 on at
    RE: How to get Marketing List Members in plug-in

    Hi Evan li,

    What are you trying to achieve with your plug-in?

    The "Targeted At" field has a schema name of createdfromcode, and a Description of "Select the type of members that this marketing list will contain: accounts, contacts, or leads. Each list can have only one member type and this value can't be changed after the marketing list is created.” The Members section is usually for displaying accounts, contacts, and leads.

  • Suggested answer
    a33ik Profile Picture
    a33ik 84,323 Most Valuable Professional on at
    RE: How to get Marketing List Members in plug-in

    Hello,

    You should look for listmember entity. It's intersect N-N entity.

    Check this article - community.dynamics.com/.../learning-how-to-query-for-marketing-list-members

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

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 Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans