Search code examples
unicodedynamics-crm-2011odatadynamics-crm

Dynamics CRM: Odata query that checks if the file attachment file name contains the unicode '#'


Scenario: I have a custom entity with attachments in Dynamics CRM 2011. I want to query those attachments with file name that contains a hash tag ('#'). Say I have attached a few text documents. kdk#ie.txt, Report.txt, & k!ke.txt to the custom entity. Here are my results to my Odata query. Error Code:

//ORGANIATION/XRMServices/2011/OrganizationData.svc/AnnotationSet?$filter=ObjectId/Id eq guid'{GUID HERE}' and IsDocument eq true and substringof('#',FileName)

Return: Bad Request

Because it is a unicode I tried the following on the string parameter. '\u0023' 'U+0021' 'w%u0023'

But return is either 0 or Bad Request

I tested '!' & 'Report' it was successful return 1 respectively. It seem it only does not work for the #.

Any ideas why I am not getting the result I expected?

Really appreciate it.

TIA


Solution

  • "#" sign is a special character in a URL. It has to be encoded to not create an invalid URL. msdn.microsoft.com/en-us/library/aa226544(SQL.80).aspx