31. Januar 2012 10:59
HideTab();
function HideTab()
{
var allowedRoles = [ "System Administrator", "Sales Manager" ];
var roleAllowed = IsRoleAllowed(allowedRoles);
if (! roleAllowed)
{
// Registerkarte 'Intern' ausblenden
tab2Tab.style.display = 'none';
}
}
function IsRoleAllowed(allowedRoles)
{
var result = RetrieveUserRoles();
var foundResult = false;
for (i=0;i<=allowedRoles.length;i++)
{
if (result.index0f(allowedRoles[i]) > -1 )
{
foundResult = true;
break;
}
}
return foundResult;
}
function RetrieveUserRoles()
{
var serverUrl = "/mscrmservices/2007/crmservice.asmx";
var xmlhttp = new ActiveX0bject("Microsoft.XMLHTTP");
xmlhttp.open("POST", serverurl, false);
xmlhttp.setRequestHeader("Content-Type", "text/xmi; charset=utf-8");
xmlhttp.setRequestHeader("SOAPAction", "http://schemas.microsoft.com/crm/2007/webServices/
RetrieveMultiple");
var message =
[
"<?xml version='1.0' encoding='utf-8'?>",
"<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"
xmlnsz xsi=\"http://www.w3.org/2001/XMLSchema-instance\"
xmlns:xsd=\"http://www.w3.org/2001/ XMLSchema\">",
GenerateAuthenticationHeader(),
"<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>role</q1:EntityName>",
"<q1:ColumnSet xsi:type='q1:ColumnSet'><q1:Attributes><q1:Attribute>name</q1:
Attribute></q1:Attributes></q1:ColumnSet>",
"<q1:Distinct>false</q1:Distinct>",
"<q1:LinkEntities><q1:LinkEntity>",
"<q1:LinkFromAttributeName>roleid</q1:LinkFromAttributeName>",
"<q1:LinkFromEntityName>role</q1:LinkFromEntityName>",
"<q1:LinkToEntityName>systemuserroles</q1:LinkToEntityName>",
"<q1:LinkToAttributeName>roleid</q1:LinkToAttributeName>",
"<q1:JoinOperator>Inner</q1:JoinOperator>",
"<q1:LinkEntities><q1:LinkEntity>",
"<q1:LinkFromAttributeName>systemuserid</q1:LinkFromAttributeName>",
"<q1:LinkFromEntityName>systemuserroles</q1:LinkFromEntityName>",
"<q1:LinkToEntityName>systemuser</q1:LinkToEntityName>",
"<q1:LinkToAttributeName>systemuserid</q1:LinkToAttributeName>",
"<q1:Join0perator>Inner</q1:Join0perator>",
"<q1:LinkCriteria><q1:Filter0perator>And</q1:Filter0perator>",
"<q1:Conditions><q1:Condition>",
"<q1:AttributeName>systemuserid</q1:AttributeName>",
"<q1:Operator>Equal</q1:0perator>",
"<q1:Values>",
"<q1:Value xmlns:q2='http://microsoft.com/wsdl/types/' xsi:type='q2:guid'>",
GetUserId(),
"</q1:Value></q1:Values></q1:Condition></q1:Conditions>",
"</q1:LinkCriteria></q1:LinkEntity></q1:LinkEntities>",
"</q1:LinkEntity></q1:LinkEntities></query></RetrieveMultiple>",
"</soap:Body></soap:Envelope>"
].join("");
xmlhttp.send (message) ;
return xmlhttp.responseXML.text;
}
function GetUserId()
{
var serverUrl = "/mscrmservices/2007/crmservice.asmx";
var xmlhttp = new ActiveX0bject("Microsoft.XMLHTTP");
xmlhttp.open("POST", serverUrl, false);
xmlhttp.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
xmlhttp.setRequestHeader("SOAPAction", "http://schemas.microsoft.com/crm/2007/WebServices/
Execute");
var message =
[
"<?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\">",
GenerateAuthenticationHeader(),
"<soap:Body>",
"<Execute xmlns='http://schemas.microsoft.com/crm/2007/webServices'>",
"<Request xsi:type='whoAmIRequest' />",
"</Execute>",
"</soap:Body>",
"</soap:Envelope>"
].join("");
xmlhttp.send(message);
var result = xmlhttp.responseXML.xml;
var doc = new ActiveX0bject("MSXML2.DOMDocument");
doc.async = false;
doc.loadXML(result);
var returnNode = doc.selectSingleNode("//UserId");
if( returnNode != null )
{
return returnNode.text;
}
else
{
return null;
}
}
31. Januar 2012 17:06
31. Januar 2012 17:47
31. Januar 2012 17:53
1. Februar 2012 13:16
<ScriptErrorDetails>
<Message>Nicht abgeschlossene Zeichenfolgenkonstante</Message>
<Line>444</Line>
<URL>/tools/formEditor/preview.aspx</URL>
<PageURL>/tools/formEditor/preview.aspx</PageURL>
<Function></Function>
<CallStack>
</CallStack>
</ScriptErrorDetails>
1. Februar 2012 15:30