如何在Microsoft CRM 4.0中搜索通配符?

时间:2010-05-10 09:33:44

标签: dynamics-crm dynamics-crm-4

我需要在Microsoft CRM中搜索帐户,使用通配符搜索来获取用户输入的“包含”搜索。因此,如果用户输入“ABC”,我使用ConditionOperator.Like和值“%ABC%”。

我的问题是,如何搜索包含百分号的客户名称,例如“100%Great llc”?我无法找到逃脱%的方法。

2 个答案:

答案 0 :(得分:1)

尝试将square blocks用于特殊字符,例如[%]。因此条件为:100[%] Great llc%100[%] Great llc%

<强> - 编辑 -

这是对你的评论的回应。

尝试使用ConditionExpression,如下所示:

//1. Condition expression.
ConditionExpression nameCondition= new ConditionExpression();
            nameCondition.AttributeName = "AccountName";
            nameCondition.Operator = ConditionOperator.Like;
            nameCondition.Values = new string[] { "%100[%] Great llc%" };

//2. Create filter expression
FilterExpression nameFilter = new FilterExpression();
nameFilter.Conditions = new ConditionExpression[] { nameCondition };

//3. Provide columns
ColumnSet resultSetColumns = new ColumnSet();
            resultSetColumns.Attributes = new string[] { "name", "address" };

//4. Prepare query expression
QueryExpression qryExpression = new QueryExpression();
            qryExpression.Criteria = nameFilter;
            qryExpression.ColumnSet = resultSetColumns;

//5. Set the table to query.
qryExpression.EntityName = EntityName.account.ToString();

//6. BusinessEntityCollection accountsResultSet = service.RetrieveMultiple(qryExpression);

虽然我已经玩了很多CRM,但从未遇到过特殊字符的情况。让我知道你的发现。 This article有一些启示。

答案 1 :(得分:1)

听起来你正在寻找一种基于SQL的方法,所以我不确定这是否有帮助。

我知道的一种方法是通过带有星号*

的用户界面

因此,如果您要查找具有%符号的所有帐户,只需在帐户搜索中键入*%即可。

相关问题