2. Juli 2010 15:37
2. Juli 2010 17:06
9. Juli 2010 14:11
10. Juli 2010 12:48
// Ermittelt die Firmennummer und Telephone1 der übergeordneten Firma im Kontakt
if (crmForm.all.parentcustomerid.DataValue != null)
{
var myAccountId = crmForm.all.parentcustomerid.DataValue[0].id;
// Define the SOAP XML to access Microsoft Dynamics CRM Web service.
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>accountnumber</q1:Attribute>" +
" <q1:Attribute>telephone1</q1:Attribute>" +
" </q1:Attributes>" +
" </q1:ColumnSet>" +
" <q1:Distinct>false</q1:Distinct>" +
" <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 xsi:type=\"xsd:string\">myAccountId</q1:Value>" +
" </q1:Values>" +
" </q1:Condition>" +
" </q1:Conditions>" +
" </q1:Criteria>" +
" </query>" +
" </RetrieveMultiple>" +
" </soap:Body>" +
"</soap:Envelope>";
// Create an instance of an XMLHTTP object.
var xmlHttpRequest = new ActiveXObject("Msxml2.XMLHTTP");
// Configure the XMLHttp object for the
// Microsoft CRM Web services.
xmlHttpRequest.Open("POST", "/mscrmservices/2007/CrmService.asmx", false);
xmlHttpRequest.setRequestHeader("SOAPAction","http://schemas.microsoft.com/crm/2007/WebServices/Retrieve");
xmlHttpRequest.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
xmlHttpRequest.setRequestHeader("Content-Length", xml.length);
// Send the XMLHttp request.
xmlHttpRequest.send(xml);
if(xmlHttpRequest.status == 200)
{
// Capture the XMLHttp response in XML format.
var resultXml = xmlHttpRequest.responseXML;
var nodeNumber = resultXml.selectNodes("//q1:accountnumber");
if (nodeNumber.length == 1)
{
crmForm.all.Field1.DataValue = parseFloat(nodeNumber[0].text);
}
var nodeTelephone = resultXml.selectNodes("//q1:telephone1");
if (nodeTelephone.length == 1)
{
crmForm.all.Field2.DataValue = parseFloat(nodeTelephone[0].text);
}
}
}
23. Juli 2010 16:52