我们最近从 CRM 2011 RU 8 迁移到 RU 18。我正在尝试通过 SOAP 调用检索自定义实体记录。它与属于根业务部门并具有系统管理员角色的用户一起工作正常。但相同的代码不适用于属于具有任何角色的任何 BU 的任何其他用户(甚至对于系统管理员),其给出错误:主要用户(Id=GUID,类型=8)缺少 prvRead[实体名称]权限(Id=GUID)
如果您对此问题有任何想法,需要帮助。
肥皂代码:
RetrieveMultiple = function(entity, attribute, condition)
{
// Usage => RetrieveMultiple("new_entityname", "new_attribute1|new_attribute2|new_attribute3", "new_attribute1||value1||new_attribute2|Like|value2||new_attribute|NotNull";
// Refer to the following link for more operators >> http://msdn.microsoft.com/en-us/library/bb959309.aspx
// Prepare variables to retrieve the records.
var attributes = attribute.split('|');
var authenticationHeader = GenerateAuthenticationHeader();
// Prepare the SOAP message.
var xml = "<?xml version='1.0' encoding='utf-8'?>" +
"<soap:Envelope xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'" +
" xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'" +
" xmlns:xsd='http://www.w3.org/2001/XMLSchema'>" +
authenticationHeader +
"<soap:Body>" +
"<RetrieveMultiple xmlns='http://schemas.microsoft.com/crm/2007/WebServices'>" +
"<query xmlns:q1='http://schemas.microsoft.com/crm/2006/Query'" +
" xsi:type='q1:QueryExpression'>" +
"<q1:EntityName>" + entity + "</q1:EntityName>" +
"<q1:ColumnSet xsi:type='q1:ColumnSet'>" +
"<q1:Attributes>";
for (i = 0; i < attributes.length; i++)
xml += "<q1:Attribute>" + attributes[i] + "</q1:Attribute>"
xml +=
"</q1:Attributes>" +
"</q1:ColumnSet>" +
"<q1:Distinct>false</q1:Distinct>" +
"<q1:Criteria>" +
"<q1:FilterOperator>And</q1:FilterOperator>" +
"<q1:Conditions>";
var conditionDetails;
var conditions = condition.split('||');
for (i = 0; i < conditions.length; i++) {
conditionDetails = conditions[i].split('|');
xml +=
"<q1:Condition>" +
"<q1:AttributeName>" + conditionDetails[0] + "</q1:AttributeName>" +
"<q1:Operator>" + conditionDetails[1] + "</q1:Operator>";
if (conditionDetails.length > 2) {
xml +=
"<q1:Values>" +
"<q1:Value xsi:type='xsd:string'>" + conditionDetails[2] + "</q1:Value>" +
"</q1:Values>";
}
xml +=
"</q1:Condition>";
}
xml +=
"</q1:Conditions>" +
"</q1:Criteria>" +
"</query>" +
"</RetrieveMultiple>" +
"</soap:Body>" +
"</soap:Envelope>";
// Prepare the xmlHttpObject and send the request.
var xHReq = new ActiveXObject("Msxml2.XMLHTTP");
xHReq.Open("POST", "/mscrmservices/2007/CrmService.asmx", false);
xHReq.setRequestHeader("SOAPAction", "http://schemas.microsoft.com/crm/2007/WebServices/RetrieveMultiple");
xHReq.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
xHReq.setRequestHeader("Content-Length", xml.length);
xHReq.send(xml);
// Capture the result.
var resultXml = xHReq.responseXML;
// Check for errors.
var errorCount = resultXml.selectNodes('//error').length;
if (errorCount != 0) {
var msg = resultXml.selectSingleNode('//description').nodeTypedValue;
//alert(msg);
return msg;
}
// Parse and display the results.
else {
var results = resultXml.getElementsByTagName('BusinessEntity');
var msg = "";
if (results.length == 0) {
//msg = "No record found with the given criteria.";
//alert(msg);
//return;
return null;
}
else {
var result = "";
for (i = 0; i < results.length; i++) {
if (i != 0)
result += '|';
for (j = 0; j < attributes.length; j++) {
if (i != 0 || j != 0)
result += '|';
if (results[i].selectSingleNode('./q1:' + attributes[j]) != null)
result += results[i].selectSingleNode('./q1:' + attributes[j]).nodeTypedValue;
}
}
return result;
}
}
}
我遇到了类似的问题,最终是基于权限的。 我们试图让所有者的业务部门具有客户服务代表的角色,并且该角色没有自定义实体的权限(因此出现错误)。
我转到业务部门 -> 然后管理角色 -> 然后单击角色 -> 然后为自定义实体的角色添加创建功能,然后为我们解决了这个问题。