I modified the code in the above thread to dynamically populate a nvarchar textbox called new_itemnumber as a picklist by selecting the product id's from the InvoiceDetail view based on an existing Invoice Id. It is not working and I am not getting an error. Any thoughts?//Dynamically populate varchar new_itemnumber as a picklist function SetItems() { var invid = crmForm.all.new_invoiceid.DataValue; var xml = "<?xml version=\"1.0\" encoding=\"utf-8\"?>"; xml += "<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\">"; xml += GenerateAuthenticationHeader(); xml += " <soap:Body>"; xml += " <RetrieveMultiple xmlns=\"http://schemas.microsoft.com/crm/2007/WebServices\">"; xml += " <query xmlns:q1=\"http://schemas.microsoft.com/crm/2006/Query\" xsi:type=\"q1:QueryExpression\">"; xml += " <q1:EntityName>invoicedetail</q1:EntityName>"; xml += " <q1:ColumnSet xsi:type=\"q1:ColumnSet\">"; xml += " <q1:Attributes>"; xml += " <q1:Attribute>productid</q1:Attribute>"; xml += "</q1:Attributes>"; xml += "</q1:ColumnSet>"; xml += "<q1:Distinct>false</q1:Distinct>"; xml += "<q1:Criteria>"; xml += "<q1:FilterOperator>And</q1:FilterOperator>"; xml += "<q1:Conditions>"; xml += "<q1:Condition>"; xml += "<q1:AttributeName>invoiceid</q1:AttributeName>"; xml += "<q1:Operator>Equal</q1:Operator>"; xml += "<q1:Values>"; xml += "<q1:Value xsi:type=\"xsd:string\">" + invid + "</q1:Value>"; xml += "</q1:Values>"; xml += "</q1:Condition>"; xml += "</q1:Conditions>"; xml += "</q1:Criteria>"; xml += "</query>"; xml += "</RetrieveMultiple>"; xml += "</soap:Body>"; xml += "</soap:Envelope>" 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); //alert(xml); var resultXml = xmlHttpRequest.responseXML; //alert(resultXml.xml); var Request = resultXml.getElementsByTagName("BusinessEntity"); if (Request.length == 0) { //alert("Aucune ville n'existe pour ce code postal"); return null; } else { if (Request[0].getElementsByTagName("q1:productid")[0] != null) { function ProdToPickList() { ConvertProdTextToPickList("new_itemnumber"); } function ConvertProdTextToPickList(controlId) { var textControl = document.getElementById(controlId); var picklistControl = document.createElement("SELECT"); picklistControl.id = textControl.id; picklistControl.req = textControl.req; picklistControl.className = "ms-crm-selectBox"; AddPickListValues(picklistControl); picklistControl.value = textControl.DataValue; textControl.parentElement.appendChild(picklistControl); textControl.parentElement.removeChild(textControl); } function AddPickListValues(picklistControl) { var items = resultXml.selectNodes("//BusinessEntity/q1:productid"); if(items != null) { for( i = 0; i < items.length; i++) { var option = document.createElement("OPTION"); option.innerText = items[i].text; picklistControl.appendChild(option); } } ProdToPickList(); } } }
GM