【问题标题】:MS Dynamics 4.0: Checking whether record exists based on email addressMS Dynamics 4.0:根据电子邮件地址检查记录是否存在
【发布时间】:2012-06-27 11:14:08
【问题描述】:

我在使用需要返回基于给定电子邮件地址的记录的 GUID 的方法时遇到问题。这是我目前拥有的:

        ColumnSet columnSet = new ColumnSet();
        columnSet.AddColumns(new[] { "leadid" });

        var query = new QueryExpression
        {
            EntityName = "lead",
            ColumnSet = columnSet
        };

        FilterExpression leadFilter = new FilterExpression();
        leadFilter.AddCondition(new ConditionExpression
        {
            AttributeName = "emailaddress1",
            Operator = ConditionOperator.Equal,
            Values = new object[] { emailAddress }
        });

        query.Criteria = leadFilter;

        BusinessEntityCollection result = crmService.RetrieveMultiple(query);

        foreach (BusinessEntity record in result)
        {
            //Guid leadId = ?? Not sure how to extract it. 
        }

A) 这似乎有点矫枉过正,因为我只需要一条记录(但不要认为我可以使用 Retrieve,因为我没有 id)。 B) 我如何在 foreach 中从上述内容中实际检索 GUID?

谢谢。

【问题讨论】:

    标签: c# asp.net dynamics-crm dynamics-crm-4


    【解决方案1】:

    A) 不能保证您只会取回一个实体,例如,可能有多个潜在客户使用相同的电子邮件地址。

    B) 您可以将BusinessEntity 转换为您查询的实体,它是所有其他实体类型的抽象基类。

    【讨论】:

      猜你喜欢
      • 2016-04-06
      • 2016-08-20
      • 2012-09-09
      • 2011-08-17
      • 1970-01-01
      • 2011-08-30
      • 2022-07-25
      • 2016-02-21
      • 1970-01-01
      相关资源
      最近更新 更多