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

Problem with ampersand in FetchXML in GetList() #101

Open
msymer opened this issue Aug 21, 2020 · 2 comments
Open

Problem with ampersand in FetchXML in GetList() #101

msymer opened this issue Aug 21, 2020 · 2 comments

Comments

@msymer
Copy link

msymer commented Aug 21, 2020

When you want to search for example for client by name "H&M" and you write this condition in FetchXML
<condition attribute="name" operator="eq" value="H&M" /> , it does not work. I tried all the combinations with & %26 ... but none is working.

Solution can be this in CrmWebAPI.cs (line 1067):

if (firstParam)
        {
          fullurl = fullurl + string.Format("?fetchXml={0}", Uri.EscapeUriString(queryOptions.FetchXml).Replace("&", "%26amp%3B"));
        }
        else
        {
          fullurl = fullurl + string.Format("&fetchXml={0}", Uri.EscapeUriString(queryOptions.FetchXml).Replace("&", "%26amp%3B"));
        }
        firstParam = false;
@WizardMatthew
Copy link

Bump, ran into the same issue. Going to have implement my own odata service for this one call...

@x4int
Copy link

x4int commented Sep 9, 2022

Not just that, but colon ( : ) doesn't work either... Which is bad, because you can't query on DateTime, if there is a time component in the query. So this doesn't work: <condition attribute="name" operator="lt" value="2022-09-09T08:00Z" />

Quick and (seems to be working) dirty fix is to use not just the FetchXml parameter for querying, but also the Filter one...

return new CRMGetListOptions { FetchXml = $@"<fetch top=""1""> ..., Filter = $"date_field le '2022-09-09T08:30Z'" };

Ugly but works. There are so much more problems with this library unfortunately...

For example, using this library with the XrmToolBox's Early Bound Generator for Crm Web Api, if you put a valid Guid value into a string field on a CRM entity, it will parse it automatically to a Guid type, which brokes the proxy classes' getter...

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

3 participants