16. August 2011 12:48
19. August 2011 15:01
24. August 2011 10:37
// Prüfen, ob das LookUp Feld überhaupt Daten enthält
if (crmForm.all.customerid.DataValue != null)
{
// Die ID des Datensatzes zuweisen
var myId = crmForm.all.customerid.DataValue[0].id;
// Definieren der SOAP XML Message für den Zugriff auf den CRM Webservice
// Hier wird auch die Funktion GenerateAuthenticationHeader verwendet, die automatisch die korrekte Anmeldung ermittelt
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\">" +
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>account</q1:EntityName>" +
" <q1:ColumnSet xsi:type=\"q1:ColumnSet\">" +
" <q1:Attributes>" +
" <q1:Attribute>new_number</q1:Attribute>" +
" </q1:Attributes>" +
" </q1:ColumnSet>" +
" <q1:Distinct>false</q1:Distinct>" +
" <q1:PageInfo>" +
" <q1:PageNumber>1</q1:PageNumber>" +
" <q1:Count>50</q1:Count>" +
" </q1:PageInfo>" +
" <q1:Criteria>" +
" <q1:FilterOperator>And</q1:FilterOperator>" +
" <q1:Conditions>" +
" <q1:Condition>" +
" <q1:AttributeName>accountid</q1:AttributeName>" +
" <q1:Operator>Equal</q1:Operator>" +
" <q1:Values>" +
" <q1:Value xmlns:q2=\"http://microsoft.com/wsdl/types/\" xsi:type=\"q2:guid\">" + myId + "</q1:Value>" +
" </q1:Values>" +
" </q1:Condition>" +
" </q1:Conditions>" +
" </q1:Criteria>" +
" </query>" +
" </RetrieveMultiple>" +
" </soap:Body>" +
"</soap:Envelope>" +
"";
// Eine Instance des XMLHTTP Objektes erzeugen
var xmlHttpRequest = new ActiveXObject("Msxml2.XMLHTTP");
xmlHttpRequest.Open("POST", "/mscrmservices/2007/CrmService.asmx", false);
xmlHttpRequest.setRequestHeader("SOAPAction", "http://schemas.microsoft.com/crm/2007/WebServices/RetrieveMultiple");
xmlHttpRequest.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
xmlHttpRequest.setRequestHeader("Content-Length", xml.length);
xmlHttpRequest.send(xml);
if(xmlHttpRequest.status == 200)
{
var resultXml = xmlHttpRequest.responseXML;
var entityNodes = resultXml.selectNodes("//RetrieveMultipleResult/BusinessEntities/BusinessEntity");
for (var i = 0; i < entityNodes.length; i++)
{
var entityNode = entityNodes[i];
var new_numberNode = entityNode.selectSingleNode("address1_postalcode");
var new_number = (new_numberNode == null) ? null : new_numberNode.text;
crmForm.all.TEST-SE.DataValue = new_number;
}
}
}
28. August 2011 10:41
<q1:Attribute>new_number</q1:Attribute>" +
<q1:Attribute>address1_postalcode</q1:Attribute>" +