7. Mai 2010 08:59
// Ermittelt Daten des Hauptkontaktes der Firma
var myId = crmForm.all.new_vertragspartnerid.DataValue[0].id;
var entityName = "new_mitarbeiterrvlieferant";
var attribute1 = "new_mrvanrede";
var attribute2 = "new_mrvvorname";
var attribute3 = "new_mrvnachname";
var attribute4 = "new_mrvposition";
var attribute5 = "new_mrvfunktion";
var filterOperator = "And";
var conditionAttribute = "new_uebergeordneterrvlieferantid";
var conditionOperator = "Equal";
var conditionValue = "Hauptkontakt";
// 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 ermittel
var xml3 = "" +
"<?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>" + entityName + "</q1:EntityName>" +
" <q1:ColumnSet xsi:type=\"q1:ColumnSet\">" +
" <q1:Attributes>" +
" <q1:Attribute>" + attribute1 + "</q1:Attribute>" +
" <q1:Attribute>" + attribute2 + "</q1:Attribute>" +
" <q1:Attribute>" + attribute3 + "</q1:Attribute>" +
" <q1:Attribute>" + attribute4 + "</q1:Attribute>" +
" <q1:Attribute>" + attribute5 + "</q1:Attribute>" +
" </q1:Attributes>" +
" </q1:ColumnSet>" +
" <q1:Criteria>" +
" <q1:FilterOperator>" + filterOperator + "</q1:FilterOperator>" +
" <q1:Conditions>" +
" <q1:Condition>" +
" <q1:AttributeName>" + conditionAttribute + "</q1:AttributeName>" +
" <q1:Operator>" + conditionOperator + "</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 xmlHttpRequest3 = new ActiveXObject("Msxml2.XMLHTTP");
xmlHttpRequest3.Open("POST", "/mscrmservices/2007/CrmService.asmx", false);
xmlHttpRequest3.setRequestHeader("SOAPAction", "http://schemas.microsoft.com/crm/2007/WebServices/RetrieveMultiple");
xmlHttpRequest3.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
xmlHttpRequest3.setRequestHeader("Content-Length", xml3.length);
xmlHttpRequest3.send(xml3);
// DEBUG: Status ausgeben
alert(xmlHttpRequest3.status);
if(xmlHttpRequest3.status == 200) {
// Capture the XMLHttp response in XML format.
var resultXml3 = xmlHttpRequest3.responseXML;
var node1 = resultXml3.selectNodes("//q1:" + attribute1);
var node2 = resultXml3.selectNodes("//q1:" + attribute2);
var node3 = resultXml3.selectNodes("//q1:" + attribute3);
var node4 = resultXml3.selectNodes("//q1:" + attribute4);
if(node1.length == 1) {
crmForm.all.new_anrede.DataValue = node1[0].text;
}
if(node2.length == 1) {
crmForm.all.new_vorname.DataValue = node2[0].text;
}
if(node3.length == 1) {
crmForm.all.new_nachname.DataValue = node3[0].text;
}
if(node4.length == 1) {
crmForm.all.new_position.DataValue = node4[0].text;
}
}
7. Mai 2010 11:48
7. Mai 2010 12:34