How to create static marketing list and associated marketing list member in Dynamics CRM 2011

To create static marketing list and associated marketing list member in Dynamics CRM 2011 below are the steps:

  1. Create the array of contacts/accounts/leads.
  2. Set type attribute as false to create static list.
  3. Make sure createdfromcode attribute is set as contact/account/lead optionset value.
  4. First create marketing list and then create associated marketing list member.
private void CreateList(Guid[] contactIds, IOrganizationService service)
{
     Entity obj = new Entity("list");
     obj.Attributes["listname"] = "Non-Responded Marketing list";
     obj.Attributes["type"] = false; // false for static marketing list
     obj["createdfromcode"] = new OptionSetValue(2); // Contact optionset value is 2
     obj.Attributes["membertype"] = 2; // Contact type is 2
     Guid listid = service.Create(obj);// Create marketing list
     // Send request to create marketing list member for above created marketing list
     AddListMembersListRequest AddMemberRequest = new AddListMembersListRequest();
     AddMemberRequest.ListId = listid; // above created marketing list id
     AddMemberRequest.MemberIds = contactIds;
     AddListMembersListResponse AddMemberResponse = service.Execute(AddMemberRequest) as AddListMembersListResponse;
}
This entry was posted in MS CRM 2011 and tagged , , . Bookmark the permalink.

Leave a Reply

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