Microsoft CRM,如何使用 CrmService 获取列表的所有成员?
我正在开发一个工具,需要使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我猜你现在可能已经明白了,但无论如何......
相关行是:
LinkFromAttributeName = "listid",
与“实体ID”
I'm guessing you probably figured it out by now but anyway...
The relevant line is:
LinkFromAttributeName = "listid",
versus "entityid"