最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Dynamics CRM Odata query filter by optionsetvalue - Stack Overflow

programmeradmin3浏览0评论

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' inpatible 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.

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' inpatible 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.
Share Improve this question asked Nov 15, 2016 at 18:51 cAMPycAMPy 6072 gold badges10 silver badges28 bronze badges 1
  • after searching for ... unfortunately hours... this question and the answer from @Wedge really saved my day in the end – D M Commented Mar 20, 2020 at 13:45
Add a ment  | 

2 Answers 2

Reset to default 6

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

Here's an exact working sample:

AccountSet?$filter=CustomerTypeCode/Value eq 1

One of my filters for Dynamics CRM 365 (on premise) looks like this

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

评论列表(0)

  1. 暂无评论