Answered by:
Using foreign characters in odata filter

Question
-
I’m trying to retrieve data from odata source:
https://xxxxxxxx.crm4.dynamics.com/xrmservices/2011/OrganizationData.svc/ContactSet?$select=FirstName,JobTitle,LastName&$filter=FirstName eq 'משה'Get empty results no error.If I change the name in the contact entity to "Moshe":
I’m getting good result. I try this in JS code and directly in the URL and getting the same results.
Its look like some encoding syntax, but I couldn't find any document/blog on the subject.
Any help will be appreciated.
Shai Bar-LevThursday, January 26, 2012 6:52 AM
Answers
-
Hi,
almost. When you escape your string with escape('משה') you get "%u05DE%u05E9%u05D4". So your Query should look like
/xrmservices/2011/OrganizationData.svc/ContactSet?$select=FirstName,JobTitle,LastName&$filter=FirstName eq '%u05DE%u05E9%u05D4'
make sure that you have the quotes around the escaped string.
regards
Uli- Proposed as answer by Ulrich Hüttinger Monday, January 30, 2012 10:41 AM
- Marked as answer by Shai BarLev Wednesday, February 1, 2012 11:46 PM
Monday, January 30, 2012 10:41 AM
All replies
-
Hi,
have you tried to escape the filter string like escape('משה');
regards
Uli
Thursday, January 26, 2012 4:47 PM -
If I do :
/xrmservices/2011/OrganizationData.svc/ContactSet?$select=FirstName,JobTitle,LastName&$filter=FirstName eq escape('משה')
I'm getting error : "HTTP 400 Bad Request"
Is this the right syntax ?
Shai Bar-LevThursday, January 26, 2012 5:33 PM -
Hi,
almost. When you escape your string with escape('משה') you get "%u05DE%u05E9%u05D4". So your Query should look like
/xrmservices/2011/OrganizationData.svc/ContactSet?$select=FirstName,JobTitle,LastName&$filter=FirstName eq '%u05DE%u05E9%u05D4'
make sure that you have the quotes around the escaped string.
regards
Uli- Proposed as answer by Ulrich Hüttinger Monday, January 30, 2012 10:41 AM
- Marked as answer by Shai BarLev Wednesday, February 1, 2012 11:46 PM
Monday, January 30, 2012 10:41 AM -
Hi Uli ,
Thanks for the the answer.
Its work in JavaScript and also in URL.
I must say that its really not "user Friendly" to try to explore data via oData URL, if you have to find a way to generate escaped string every time you looking for different contact or any other information.
Best wishes
Shai
Shai Bar-Lev- Edited by Shai BarLev Wednesday, February 1, 2012 11:48 PM Spelling
Wednesday, February 1, 2012 11:46 PM -
-
Thanks Ulrich,
Its really helped me to find the solution of my problem. I'm using like this
function checkBUName()
{
var name = Xrm.Page.getAttribute('name').getValue();
name = escape(name);
//alert(name);
var buCollection = RetrieveOdata('BusinessUnit', 'Name', "Name eq '" + name + "'");
alert(buCollection[0].results.length);
}function RetrieveOdata(prmEntityName, prmEntityColumns, prmFilterCondition)
{
var oDataUri = Xrm.Page.context.getServerUrl()
+ "/xrmservices/2011/OrganizationData.svc/" + prmEntityName
+ "Set?$select=" + prmEntityColumns + "&$filter = " + prmFilterCondition;alert(oDataUri);
....
}
Regards,
Praveen CRM Developer
Friday, June 26, 2015 10:02 AM