简体   繁体   English

无法使用估算的关闭日期对Dynamics CRM“机会”交易类型执行过滤

[英]Not able to perform Filter on Dynamics CRM “Opportunity” transaction type with estimatedclosedate

I am using QueryExpression to generate the filter for the Dynamics crm filters and then passing that to the my CRM made service to retrieve the result. 我正在使用QueryExpression为Dynamics crm筛选器生成筛选器,然后将其传递给我的CRM制作的服务以检索结果。

QueryExpression queryCRM = new QueryExpression
                {
                    EntityName = SourceID,
                    ColumnSet = new ColumnSet(FieldSet),
                    Criteria = new FilterExpression()
                };

and then 接着

queryCRM.Criteria.AddCondition(strFilterColumnName,ConditionOperator.On , strFilterValue);

Here i am not able to fetch the result can anybody help me to figure out the issue? 在这里我无法获取结果,有人可以帮助我解决问题吗? It doesn't work for "estimatedclosedate" other than this it works fine withe all other columns. 它不适用于“ estimatedclosedate”,除此之外,它与所有其他列均能正常工作。

Note := Initially it seems like an operator issue so i used "ConditionOperator.On" , so it solved my issue for Incident but not for opportunity. 注意:=最初似乎是操作员问题,所以我使用了“ ConditionOperator.On”,所以它解决了我的问题,但不是偶然的。

Need solution from the CRM experts out there. 需要那里的CRM专家提供解决方案。

Thank You. 谢谢。

Is strFilterValue a string? strFilterValue是字符串吗? Try and pass this parameter as a DateTime. 尝试将此参数作为DateTime传递。 It would help if you could post this section of code in it's entirety. 如果您可以完整地发布此部分代码,则将有所帮助。 Here's some sample code which demonstrates the use of filtering an opportunity by estimated close date. 这是一些示例代码,演示了如何根据估计的截止日期过滤机会。

        var estimatedCloseDate = DateTime.Parse("2014-10-07");
        Guid createdId = Guid.Empty;
        Entity matchingEntity = null;

        try
        {
            // Create a test opp
            var opp = new Entity("opportunity");
            opp["name"] = "Testing Date Filter";
            opp["customerid"] = new EntityReference("account", Guid.Parse("b9b0ed35-2a11-4fb6-a56f-5b8c04a3c1d1")); // A valid customer
            opp["estimatedclosedate"] = estimatedCloseDate;
            createdId = _service.Create(opp);
            Console.WriteLine("Created Id: {0}", createdId);

            // Create the filter expression
            QueryExpression queryCRM = new QueryExpression
            {
                EntityName = "opportunity",
                ColumnSet = new ColumnSet(true)
            };
            queryCRM.Criteria.AddCondition("estimatedclosedate", ConditionOperator.On, estimatedCloseDate);

            // Run the search and check for a match vs the record just created
            var results = _service.RetrieveMultiple(queryCRM);
            foreach (var result in results.Entities)
            {
                if (result.Id == createdId)
                {
                    matchingEntity = result;
                }
            }

            // Survey says... 
            Console.WriteLine(matchingEntity == null
                                ? "Matching entity not found!"
                                : "Matching entity found!");
        }
        finally
        {
            // Delete the created opp
            if (createdId != Guid.Empty)
            {
                _service.Delete("opportunity", createdId);
            }
        }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM