Microsoft CRM,如何使用 CrmService 获取列表的所有成员?

发布于 2024-08-13 19:35:20 字数 1326 浏览 6 评论 0原文

我正在开发一个工具,需要使用 Web 服务 API 从 Microsoft CRM 读取数据。

我需要获取营销列表的所有成员。我可以使用网络服务获取系统中的所有列表,但无法获取列表的成员。这是我到目前为止可以运行的查询,但它不返回任何成员:

QueryExpression qe = new QueryExpression();
qe.EntityName = "contact";
qe.ColumnSet = new AllColumns();

var linkContact = new LinkEntity { 
    LinkFromEntityName = "contact", 
    LinkFromAttributeName = "contactid", 
    LinkToEntityName = "listmember",
    LinkToAttributeName = "entityid"
};  

var linkList = new LinkEntity {
    LinkFromEntityName = "listmember",
    LinkFromAttributeName = "entityid",
    LinkToEntityName = "list",
    LinkToAttributeName = "listid" };

var ce = new ConditionExpression
             {
                 AttributeName = "listid",
                 Operator = ConditionOperator.Equal,
                 Values = new object[] {list.listid.Value}
             };

linkList.LinkCriteria = new FilterExpression {Conditions = new[] {ce}};
linkContact.LinkEntities = new[] {linkList};
qe.LinkEntities = new [] {linkContact};
var members = service.RetrieveMultiple(qe);
Console.WriteLine("Members of {0}:", list.listname);
Assert.IsTrue(members.BusinessEntities.Any());

foreach(contact lead in members.BusinessEntities)
    Console.WriteLine(lead.fullname);

How can I get the Members of the list using the webservice API ?

I am developing a tool that needs to read data from Microsoft CRM using the webservice API.

I need to get all the members of a marketing list. I can get all the lists in the system using the webservice, but I can't get the members of a list. This is the query I have so far, which I can run, but it does not return any members:

QueryExpression qe = new QueryExpression();
qe.EntityName = "contact";
qe.ColumnSet = new AllColumns();

var linkContact = new LinkEntity { 
    LinkFromEntityName = "contact", 
    LinkFromAttributeName = "contactid", 
    LinkToEntityName = "listmember",
    LinkToAttributeName = "entityid"
};  

var linkList = new LinkEntity {
    LinkFromEntityName = "listmember",
    LinkFromAttributeName = "entityid",
    LinkToEntityName = "list",
    LinkToAttributeName = "listid" };

var ce = new ConditionExpression
             {
                 AttributeName = "listid",
                 Operator = ConditionOperator.Equal,
                 Values = new object[] {list.listid.Value}
             };

linkList.LinkCriteria = new FilterExpression {Conditions = new[] {ce}};
linkContact.LinkEntities = new[] {linkList};
qe.LinkEntities = new [] {linkContact};
var members = service.RetrieveMultiple(qe);
Console.WriteLine("Members of {0}:", list.listname);
Assert.IsTrue(members.BusinessEntities.Any());

foreach(contact lead in members.BusinessEntities)
    Console.WriteLine(lead.fullname);

How can I get the members of the list using the webservice API ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

远山浅 2024-08-20 19:35:20

我猜你现在可能已经明白了,但无论如何......

var linkList = new LinkEntity {
            LinkFromEntityName = "listmember",
            LinkFromAttributeName = "listid",
            LinkToEntityName = "list",
            LinkToAttributeName = "listid" };

相关行是:
LinkFromAttributeName = "listid",
与“实体ID”

I'm guessing you probably figured it out by now but anyway...

var linkList = new LinkEntity {
            LinkFromEntityName = "listmember",
            LinkFromAttributeName = "listid",
            LinkToEntityName = "list",
            LinkToAttributeName = "listid" };

The relevant line is:
LinkFromAttributeName = "listid",
versus "entityid"

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文