Problem with ampersand in FetchXML in GetList()
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;
Bump, ran into the same issue. Going to have implement my own odata service for this one call...
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...