简体   繁体   English

Dynamics CRM Odata 查询过滤器按选项集值

[英]Dynamics CRM Odata query filter by optionsetvalue

How do I filter records by optionset value?如何按选项集值过滤记录? I am trying like this:我正在尝试这样:

 "$select=new_id&$filter=new_campaignid/Id eq guid'" + myId+ "' and new_optionsetfield eq '" + optionsetCode + "'"

But this does not work.但这不起作用。 I keep on getting bad request with error message:我不断收到错误消息的错误请求:

Operator 'eq' incompatible with operand types 
'Microsoft.Crm.Metadata.ComplexTypeInstance`1[[Microsoft.Xrm.Sdk.OptionSetValue, Microsoft.Xrm.Sdk, Version=8.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]' 
and 'System.String' at position 96.

I'm pretty sure this is what you need:我很确定这是你需要的:

"$select=new_id&$filter=new_campaignid/Id eq guid'" + myId+ "' and new_optionsetfield/Value eq " + optionsetCode

Edited: Removed the quotes, because that is an int value, not a string编辑:删除了引号,因为那是一个 int 值,而不是一个字符串

Here's an exact working sample:这是一个确切的工作示例:

AccountSet?$filter=CustomerTypeCode/Value eq 1

我的 Dynamics CRM 365(内部部署)过滤器之一如下所示

var filter = "(substringof('SomeStringValue', Description) eq false) and (StatusCode/Value ne 1)";

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

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