简体   繁体   中英

Creating a Marketing List in CRM Dynamics 2013

I'm new to both Microsoft CRM and C# development, but I've been tasked with creating a process that creates a marketing list and then adds members (contacts) to that list.

So far the only example I've found for creating a marketing list is here: http://mubashersharif.blogspot.com/2013/06/create-dynamic-marketing-list-in-crm.html

However, when I try this:

List dynamicList = new List()
{
    Type = true, //True for Dynamic List
    ListName = "Dynamic List", //Name of the List
    CreatedFromCode = 2, //1 For Account; 2 For Contact; 3 For Lead
    Query = fetchXml
};
Guid _dynamicListId = service.Create(dynamicList);

I get the error Using the generic type 'System.Collections.Generic.List<T>' requires 1 type arguments.

I assume this is because it's expecting a List<T> and not a CRM List entity. I'm not sure how to specify List and not List<T> . Can anyone offer some insight?

Thanks,

Just add a Microsoft.Xrm.Sdk using and remove System.Collections.Generic using, or use an alias to distinguish them:

using crm = Microsoft.Xrm.Sdk;

Then,

crm.List dynamicList = new crm.List()
{
   Type = true, //True for Dynamic List
   ListName = "Dynamic List", //Name of the List
   CreatedFromCode = 2, //1 For Account; 2 For Contact; 3 For Lead
   Query = fetchXml
};

Jordi's answer is a good one. I ended up using this:

Guid _MarketingList
Entity _List = new Entity("list");
OptionSetValue _Createdfromcode = new OptionSetValue(2);

_List["listname"] = "Test Marketing List";
_List["createdfromcode"] = _Createdfromcode;
_List["type"] = false;

_MarketingList = service.Create(_List);

Thanks!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM