Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Contains is not supported in FetchXml #708

Closed
rappen opened this issue May 4, 2022 · 3 comments
Closed

Contains is not supported in FetchXml #708

rappen opened this issue May 4, 2022 · 3 comments

Comments

@rappen
Copy link
Owner

rappen commented May 4, 2022

Error of Contains operator, here with a super simple query (see in the end).

Related to #706

This docs says it should work, but give a SQL error, but this one gets a Fetch XML error, just
"Unknown Condition Operator: contains".

Tried some code to convert from QueryExpression to FetchXml.
Code:

var query = new QueryExpression("kbarticle");
query.ColumnSet.AddColumns("title");
query.Criteria.AddCondition("content", ConditionOperator.Contains, "A");
var fetch = (Service.Execute(new QueryExpressionToFetchXmlRequest { Query = query }) as QueryExpressionToFetchXmlResponse).FetchXml;

I get a bit more info - it fails with exception
"Unknown Condition Operator: Contains. FetchXml does not support it".

Which seems to mean that some features work in QX, but not in Fetch. I know the reverse, but not this!
Are there more features supported in QX but not in Fetch? Is this documented? I am just a bad Binging person...
Has @JimDaly any more info/link?


Error message from FetchXML Builder below:


System.ServiceModel.FaultException<Microsoft.Xrm.Sdk.OrganizationServiceFault>:
Unknown Condition Operator: contains
mscorlib

Server stack trace: 
- System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)
- System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
- System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
- System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

Exception rethrown at [0]: 
- Microsoft.Xrm.Tooling.Connector.CrmServiceClient.RetrieveMultiple(QueryBase query)
- Cinteros.Xrm.FetchXmlBuilder.FetchXmlBuilder.<>c__DisplayClass112_0.<RetrieveMultiple>b__0(BackgroundWorker worker, DoWorkEventArgs eventargs)
- System.ComponentModel.BackgroundWorker.OnDoWork(DoWorkEventArgs e)
- System.ComponentModel.BackgroundWorker.WorkerThreadStart(Object argument)

<fetch>
  <entity name="account">
    <attribute name="name" />
    <filter>
      <condition attribute="name" operator="contains" value="A" />
    </filter>
  </entity>
</fetch>

  • XrmToolBox Version: 1.2022.4.55
  • FetchXML Builder Version: 1.2022.4.1
  • DB Version: 9.2.22041.157
  • Deployment: Online
@JimDaly
Copy link

JimDaly commented May 4, 2022

@rappen
Looking at the FetchXml Schema I don't see a definition for CONTAINS.
We can see it is in the ConditionOperator used by QueryExpression. I expected to find it in the FetchXml Schema, but it isn't there.

@rappen
Copy link
Owner Author

rappen commented May 4, 2022

Right.
So where is the bug...?
In me or MS? 😉

A bit funny that I can find contain-values and not-contain-values, but not the simpler like contains...

A few years back, I got clear fact that MS is not anymore updating the FetchXml Schema that I used to use in this tool as a "fact" for the code. This is why I can not use that anymore... (I did earlier find it in the SDK we had downloaded)

@JimDaly
Copy link

JimDaly commented May 5, 2022

contains-values and not-contains-values are relatively new to support multi-select optionsets.
Contains has been around a long time and is pretty much only used for certain KB articles attributes that have special indexing. The error message is pretty clear, but I don't see it documented anywhere.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants