How to retrieve static marketing list member in Dynamics CRM 2011

To retrieve static marketing list member in Dynamics CRM 2011 follow below steps:

  • Use Link Entities to get relationship entity details
  • Passing list Guid as object and it will return static marketing list member
 private EntityCollection RetrieveMarketingListMembers(IOrganizationService service, object strList)
        {
            QueryExpression qe = new QueryExpression();
            qe.EntityName = "contact";
            //Initialize columnset
            ColumnSet col = new ColumnSet();

            //add columns to columnset for the contact to retrieve each contact from the marketing list
            col.AddColumns(new string[] { "contactid", "lastname", "address1_line1", "address1_line2", "address1_city", "address1_stateorprovince", "address1_postalcode" });

            qe.ColumnSet = col;

            // link from contact to listmember
            LinkEntity le = new LinkEntity();
            le.LinkFromEntityName = "contact";
            le.LinkFromAttributeName = "contactid";
            le.LinkToEntityName = "listmember";
            le.LinkToAttributeName = "entityid";

            //link from listmember to list
            LinkEntity le2 = new LinkEntity();
            le2.LinkFromEntityName = "listmember";
            le2.LinkFromAttributeName = "listid";
            le2.LinkToEntityName = "list";
            le2.LinkToAttributeName = "listid";
            le2.LinkCriteria.AddCondition("listid", ConditionOperator.Equal, strList);

            //add linkentity2 to linkentity
            le.LinkEntities.Add(le2);

            qe.LinkEntities.Add(le);

            EntityCollection listmemberec = service.RetrieveMultiple(qe);
            return listmemberec;
        }
This entry was posted in MS CRM 2011 and tagged , . Bookmark the permalink.

2 Responses to How to retrieve static marketing list member in Dynamics CRM 2011

  1. Developer says:

    Thanks for such simple explanation, for complex inner joins of contact and marketing List

Leave a Reply

Your email address will not be published. Required fields are marked *