MSCRM 2011 中使用OData 筛选条件传值为中文出现问题
I use this method to determine whether the current user has this roleName;but when i invock this method and pass Chinest String Parameters as CurrentUserHasRole('系统管理员'), it'll return the wrong result.
我用这个方法去判定当前用户是否含有此角色,但是当我传中文参数(例如‘系统管理员’)去调用此方法时,却获取不到正确的值,
Any one who can help me?
Thanks!
function CurrentUserHasRole(roleName) {
var serverUrl = Xrm.Page.context.getServerUrl();
var oDataEndpointUrl = serverUrl + "/XRMServices/2011/OrganizationData.svc/";
oDataEndpointUrl += "RoleSet?$top=1&$filter=Name eq '" + roleName + "'";
var service = GetRequestObject();
if (service != null) {
service.open("GET", oDataEndpointUrl, false);
service.setRequestHeader("X-Requested-Width", "XMLHttpRequest");
service.setRequestHeader("Accept", "application/json, text/javascript, */*");
service.send(null);
var requestResults = eval('(' + service.responseText + ')').d;
if (requestResults != null && requestResults.results.length == 1) {
var role = requestResults[0];
var id = role.RoleId;
var currentUserRoles = Xrm.Page.context.getUserRoles();
for (var i = 0; i < currentUserRoles.length; i++) {
var userRole = currentUserRoles[i];
if (GuidsAreEqual(userRole, id)) {
return true;
}
}
}
}
return false;
}
补充:企业软件 , 企业信息化