在 CRM Dynamics 2013 中创建营销列表

Creating a Marketing List in CRM Dynamics 2013

我是 Microsoft CRM 和 C# 开发的新手,但我的任务是创建一个流程来创建营销列表,然后将成员(联系人)添加到该列表。

到目前为止,我找到的创建营销列表的唯一示例是:http://mubashersharif.blogspot.com/2013/06/create-dynamic-marketing-list-in-crm.html

但是,当我尝试这样做时:

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);

我收到错误 Using the generic type 'System.Collections.Generic.List<T>' requires 1 type arguments.

我认为这是因为它期待 List<T> 而不是 CRM 列表实体。我不确定如何指定 List 而不是 List<T>。谁能提供一些见解?

谢谢,

只需添加一个 Microsoft.Xrm.Sdk using 并删除 System.Collections.Generic using,或者使用别名来区分它们:

using crm = Microsoft.Xrm.Sdk;

然后,

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 的回答很好。我最终使用了这个:

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);

谢谢!