gpt4 book ai didi

c# - 如何使用 Dynamics CRM SDK 搜索潜在客户或客户?

转载 作者:太空狗 更新时间:2023-10-30 00:07:58 26 4
gpt4 key购买 nike

有人可以提供在 CRM SDK 中通过电子邮件检索潜在客户的示例代码吗?是否有像这样工作的内置函数?

Guid leadID = someLeadManager.GetByEmail(email);

最佳答案

假设您已获得服务,您可以执行以下查询。

private Guid GetGuidByEmail(String email)
{
QueryExpression query = new QueryExpression
{
EntityName = "lead",
ColumnSet = new ColumnSet("emailaddress1"),
Criteria = new FilterExpression
{
Filters =
{
new FilterExpression
{
Conditions =
{
new ConditionExpression(
"emailaddress1", ConditionOperator.Equals, email)
}
}
}
}
};

Entity entity = service.RetrieveMultiple(query).Entities.FirstOrDefault();
if(entity != null)
return entity.Id;
return Guid.Empty;
}

现在,如果您需要过滤电子邮件的部分匹配项,查询会变短,您可以像这样使用 LINQ 进行选择。

private IEnumerable<Guid> GetGuidsByEmail(String email)
{
QueryExpression query = new QueryExpression
{
EntityName = "lead",
ColumnSet = new ColumnSet("emailaddress1")
};
IEnumerable<Entity> entities = service.RetrieveMultiple(query).Entities;

return entities
.Where(element => element.Contains("emailaddress1"))
.Where(element => Regex.IsMatch(element["emailaddress1"], email))
.Select(element => element.Id);
}

关于c# - 如何使用 Dynamics CRM SDK 搜索潜在客户或客户?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15021144/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com