Passing special characters For Odata request using JavaScript in Dynamics CRM 2015

By | September 7, 2015

To retrieve records from Dynamics CRM using JavaScript one of the popular options is using CRM Odata services using REST endpoint.

There are many situations occurs when we need to retrieve records from CRM by name using REST retrieve multiple request. For example in below script we are retrieving products by product name.odata

While passing filter parameter as string always need to consider special characters and here is what makes difference. In Dynamics CRM 2013 to handle special characters we need to replace special characters with its ASCII code for example “&” for character “&” and “"” for single quote “ ’ ” as shown in below screen shot.odata1

But this way to handle special characters will not work in Dynamics CRM 2015. In CRM 2015 these special characters are no more supported in there ASCII format this will throw an error for special characters.

To resolve the problem for character “&” we can use hexcode for the same that is “%26” but this is not a solution for other special characters. For single quote we cannot use its hexode “%39” this will throw error we instead we can replace “ ’ ”  with two single quotes “ ‘’ ” and this will work. For characters greater than  “>” and less than “<” there is no need to replace character they are supported as it is in 2015.

Get more from your Dynamics CRM.. Dynamics CRM & QuickBooks Integration. For more details get in touch on crm@inogic.com.