• 根据订单号查询出订单附属实体


    var orderNumber =event.srcElement;
    if(IsNull(orderNumber.DataValue)==false)
    {
    
    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:QueryByAttribute\">" + 
    "        <q1:EntityName>salesorder</q1:EntityName>" + 
    "        <q1:ColumnSet xsi:type=\"q1:ColumnSet\">" + 
    "          <q1:Attributes>" + 
    "            <q1:Attribute>ordernumber</q1:Attribute>" + 
    "            <q1:Attribute>new_nsrsbh</q1:Attribute>" +       
    "            <q1:Attribute>name</q1:Attribute>" + 
    "            <q1:Attribute>totalamount</q1:Attribute>" + 
    "          </q1:Attributes>" + 
    "        </q1:ColumnSet>" + 
    "        <q1:Attributes>" + 
    "          <q1:Attribute>ordernumber</q1:Attribute>" + 
    "        </q1:Attributes>" + 
    "        <q1:Values>" + 
    "          <q1:Value xsi:type=\"xsd:string\">"+orderNumber.DataValue+"</q1:Value>" + 
    "        </q1:Values>" + 
    "      </query>" + 
    "    </RetrieveMultiple>" + 
    "  </soap:Body>" + 
    "</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);
    
    var resultXml = xmlHttpRequest.responseXML;
    var nsrsbh = resultXml.getElementsByTagName("q1:new_nsrsbh")[0].childNodes[0].nodeValue;
    crmForm.all.new_nsrsbh.DataValue=nsrsbh;
    var name =resultXml.selectSingleNode("//q1:name").text;
    crmForm.all.new_ddmc.DataValue=name;
    var id=resultXml.selectSingleNode("//q1:salesorderid").text;
    crmForm.all.new_ddsf.DataValue=resultXml.selectSingleNode("//q1:totalamount").text;
    
    //*****************根据订单ID得到产品*********************
    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>new_ddxy</q1:EntityName>" + 
    "        <q1:ColumnSet xsi:type=\"q1:ColumnSet\">" + 
    "          <q1:Attributes>" + 
    "            <q1:Attribute>new_yxqq</q1:Attribute>" + 
    "            <q1:Attribute>new_yxqz</q1:Attribute>" + 
    "            <q1:Attribute>new_productpricelevel_kz</q1:Attribute>" + 
    "          </q1:Attributes>" + 
    "        </q1:ColumnSet>" + 
    "        <q1:Distinct>false</q1:Distinct>" + 
    "        <q1:Criteria>" + 
    "          <q1:FilterOperator>And</q1:FilterOperator>" + 
    "          <q1:Conditions>" + 
    "            <q1:Condition>" + 
    "              <q1:AttributeName>new_salesorder</q1:AttributeName>" + 
    "              <q1:Operator>Equal</q1:Operator>" + 
    "              <q1:Values>" + 
    "                <q1:Value xmlns:q2=\"http://microsoft.com/wsdl/types/\" xsi:type=\"q2:guid\">"+id+"</q1:Value>" + 
    "              </q1:Values>" + 
    "            </q1:Condition>" + 
    "          </q1:Conditions>" + 
    "        </q1:Criteria>" + 
    "      </query>" + 
    "    </RetrieveMultiple>" + 
    "  </soap:Body>" + 
    "</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);
    
    var resultXml = xmlHttpRequest.responseXML;
    
                var entities = resultXml.getElementsByTagName("BusinessEntity");
                 for (var i = 0; i < entities.length; i++) {
                     var ddxy= new Object();
                     ddxy.yxqq= entities[i].selectSingleNode("//q1:new_yxqq/@date").text;
                     ddxy.yxqz =entities[i].selectSingleNode("//q1:new_yxqz/@date").text;
                     ddxy.cpid=entities[i].selectSingleNode("//q1:new_productpricelevel_kz ").text;
                     ddxy.cpmc =entities[i].selectSingleNode("//q1:new_productpricelevel_kz/@name").text;
                   //******************根据价目表项扩展ID查询价目表项扩展
                     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>" + 
    "    <Retrieve xmlns=\"http://schemas.microsoft.com/crm/2007/WebServices\">" + 
    "      <entityName>new_productpricelevel_kz</entityName>" + 
    "      <id>"+ ddxy.cpid+"</id>" + 
    "      <columnSet xmlns:q1=\"http://schemas.microsoft.com/crm/2006/Query\" xsi:type=\"q1:ColumnSet\">" + 
    "        <q1:Attributes>" + 
    "          <q1:Attribute>new_sftb</q1:Attribute>" + 
    "          <q1:Attribute>new_fwxmdm</q1:Attribute>" + 
    "          <q1:Attribute>new_cpxmdm</q1:Attribute>" + 
    "          <q1:Attribute>new_cbfy</q1:Attribute>" + 
    "        </q1:Attributes>" + 
    "      </columnSet>" + 
    "    </Retrieve>" + 
    "  </soap:Body>" + 
    "</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/Retrieve");
    xmlHttpRequest.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
    xmlHttpRequest.setRequestHeader("Content-Length", xml.length);
    xmlHttpRequest.send(xml);
    
    var resultXml = xmlHttpRequest.responseXML; 
    var sftb =resultXml.selectSingleNode("//q1:new_sftb").text;
    if(sftb==1)
    {
    if (resultXml.selectSingleNode("//q1:new_fwxmdm")!=null)
    crmForm.all.new_fwxmdm.DataValue=resultXml.selectSingleNode("//q1:new_fwxmdm").text;
    var fwcpdm=resultXml.selectSingleNode("//q1:new_cpxmdm").text;
    if(resultXml.selectSingleNode("//q1:new_cbfy")!=null)
    crmForm.all.new_cpfy.DataValue=resultXml.selectSingleNode("//q1:new_cbfy").text
    crmForm.all.new_cpmc.DataValue=ddxy.cpmc;
    crmForm.all.new_yxqq.DataValue =ddxy.yxqq;
    crmForm.all.new_yxqz.DataValue =ddxy.yxqz;
    
    crmForm.all.new_fwcpdm.DataValue=fwcpdm;
    
    
    }
    
                    
                   
     
                 }
    
    
    }
    
  • 相关阅读:
    网站负载均衡判断
    端口扫描nmap+masscan
    Ant Design Upload 组件之阻止文件默认上传
    Hybrid App技术解析
    react 路由
    webpack进阶(二)
    webpack进阶(一)
    webpack基础
    Promise原理及实现
    TS——类
  • 原文地址:https://www.cnblogs.com/hellohongfu/p/1784687.html
Copyright © 2020-2023  润新知