提问人:ThibC 提问时间:10/24/2023 最后编辑:ThibC 更新时间:10/25/2023 访问量:61
使用 fetchXML 和特殊字符“&”过滤查找不起作用
Filter lookup with fetchXML and special character '&' does not work
问:
我目前正在尝试使用 javascript 中的 fetchXML 筛选 Dynamics 365 CRM 中的查找字段。我必须查看所有自定义文本字段(“my_variantstatus”)不等于“研发阶段”(以及其他一些值)的产品。我对字符“&”有疑问。
这是我的过滤器xml:
var filterXml = "<filter type='and'><condition attribute='my_variantstatus' operator='ne' value='R&D stage'/><condition attribute='my_variantstatus' operator='ne' value='Discontinued'/></filter>";
我已经尝试过用 : , , , 重新替换 & 符号 '&',但它们都不起作用。\&
&
&
encodeURIComponent('R&D stage')
%26
请注意,当我尝试在没有 & 符号('RD stage')的情况下进行过滤时,该脚本运行良好,并且它不适用于任何其他特殊字符(引用、<、>等)。
答:
0赞
Arun Vinoth-Precog Tech - MVP
10/25/2023
#1
这是一个常见的问题,请尝试编码来解决它。
var item = 'R&D stage';
var encodedItem = encodeURIComponent(item);
var filterXml = "<filter type='and'><condition attribute='my_variantstatus' operator='ne' value= '"+ encodedItem +"'/><condition attribute='my_variantstatus' operator='ne' value='Discontinued'/></filter>";
评论
0赞
ThibC
10/25/2023
它没有用。 只是将 & 符号替换为 ,将空格替换为 ,所以现在它过滤(测试)。encodeURIComponent
%26
%20
R%26D%20stage
0赞
Arun Vinoth-Precog Tech - MVP
10/25/2023
@ThibC 在没有看到整个代码的情况下,我不确定,这段代码过去对我有用。armanino.com/articles/......也看看这个博客
评论