Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Retrieve members of a Static marketing list

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hi,

I need to retrieve members of a marketing list but i have no idea how?

Thank you for all answers.

*This post is locked for comments

  • Verified answer
    Emre GULCAN Profile Picture
    Emre GULCAN 2,379 on at
    RE: Retrieve members of a Static marketing list

    Hi,

    What is purpose of this lines? Actually there are some typo-faults and wrong usage inside.

    Entity description = new Entity("campaign");
    description["description"] = "Tu bodo napisani memberji";
    description["descriptio"] = "Tu bodo napisani memberji";
    memberGuids.Add("Jhon Doe");


  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Retrieve members of a Static marketing list

    I dont get any error's all goes through fine. Problem is that 

     EntityCollection entityCollection = service.RetrieveMultiple(query);
     Entity description = new Entity("campaign");


    entityCollection seems to be empty and I dont know reason why.

  • Gopalan Bhuvanesh Profile Picture
    Gopalan Bhuvanesh 11,401 on at
    RE: Retrieve members of a Static marketing list

    Hi

    What is the error you are getting?

    Please provide the details.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Retrieve members of a Static marketing list

    Ok i used this code but something is wrong and i dont know what(not best at debuging) i dont get anything to Array.

    Code:

    using Microsoft.Xrm.Sdk;
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using Microsoft.Xrm.Sdk.Query;
    using System.Collections;
    using Microsoft.Xrm.Sdk.Client;
    using System.ServiceModel.Description;
    
    
    namespace PluginMARetriveMembers
    {
        public class PlugInEvent : IPlugin
        {
            //public IOrganizationService OrganizationService { get; private set; }
    
            public void Execute(IServiceProvider serviceProvider)
            {
    
                //definition of context and services
                IPluginExecutionContext context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));
                IOrganizationServiceFactory servicefactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
                IOrganizationService client = servicefactory.CreateOrganizationService(context.UserId);
                IOrganizationService service = (IOrganizationService)servicefactory.CreateOrganizationService(context.UserId);
    
    
    
             
    
                ArrayList memberGuids = new ArrayList();
               // IOrganizationService orgService = OrganizationService;
                PagingInfo pageInfo = new PagingInfo();
                pageInfo.Count = 5000;
                pageInfo.PageNumber = 1;
                QueryByAttribute query = new QueryByAttribute("members");
                // GUID to static market list
                query.AddAttributeValue("listid", new Guid("9396465b-bf06-e711-80e3-3863bb358c80"));
                query.ColumnSet = new ColumnSet(true);
                EntityCollection entityCollection = service.RetrieveMultiple(query);
                Entity description = new Entity("campaign");
                description["description"] = "Tu bodo napisani memberji";
                description["descriptio"] = "Tu bodo napisani memberji";
                memberGuids.Add("Jhon Doe");
    
    
    
                foreach (Entity entity in entityCollection.Entities)
                {
                    memberGuids.Add(((EntityReference)entity.Attributes["entityid"]).Id);
                    
                }
                
                
                Console.WriteLine("!TEST!");
                // more than 5000 contacts
                while (entityCollection.MoreRecords)
                {
                    query.PageInfo.PageNumber += 1;
                    query.PageInfo.PagingCookie = entityCollection.PagingCookie;
                    entityCollection = service.RetrieveMultiple(query);
                    foreach (Entity entity in entityCollection.Entities)
                    {
                        memberGuids.Add(((EntityReference)entity.Attributes["entityid"]).Id);
                    }
                    
                }
            }
            
          
    
            }
    }
    
    
    


  • Emre GULCAN Profile Picture
    Emre GULCAN 2,379 on at
    RE: Retrieve members of a Static marketing list

    Hi,

    You can retrieve your list members without regarding to your list type (dynamic or static) with XrmLibrary (download from NuGet)

    ListHelper helper = new ListHelper(_organizationService);
    var members = helper.GetMemberList(Guid.Parse("YOUR MARKETING LIST ID")); //this returns "ListMemberResult" class
    
    foreach (var item in members.Data)
    {
       Guid id = item.Id;
       string fullname = item.Name; //If your membertype is Contact or Lead this will be "FULLNAME", if membertype is Account this will be "NAME"
    }


  • Nithya Gopinath Profile Picture
    Nithya Gopinath 17,076 on at
  • Verified answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Retrieve members of a Static marketing list

    get entityid column from list member entity. This would be the Entity Reference of contact associated with that list member.

  • Suggested answer
    Rajat Awasthi Profile Picture
    Rajat Awasthi 675 on at
    RE: Retrieve members of a Static marketing list

    Hi ,

    You need to get members according to your list id.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Retrieve members of a Static marketing list

    Ok, thank you for all answers. I have a new problem now, i got all members but now I need to get contacts from members who are in marketing list, any ideas?

  • Suggested answer
    Nithya Gopinath Profile Picture
    Nithya Gopinath 17,076 on at

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,356 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans