我们最近从CRM 2011 RU 8迁移到RU 18.我正在尝试通过SOAP调用检索自定义实体记录。它适用于属于root业务部门并具有系统管理员角色的用户。但是相同的代码不适用于属于具有任何角色的任何BU的任何其他用户(即使对于系统管理员),其给出错误:主要用户(Id = GUID,type = 8)缺少prvRead [entity name]特权(Id = GUID)
如果你对这个问题有任何想法,需要帮助。
SOAP代码:
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;
}
}
}
答案 0 :(得分:0)
我有一个类似的问题,最终以权限为基础。我们试图成为业主的业务部门担任客户服务代表的角色,该角色没有自定义实体的权限(因此错误)。
我去了业务部门 - &gt;然后管理角色 - &gt;然后点击角色 - &gt;然后为自定义实体的角色添加了创建功能,然后为我们解决了这个问题。