zoukankan      html  css  js  c++  java
  • Dynamics CRM 4.0 一个长的脚本

    if(IsNull(crmForm.all.new_pricelevel_kzid)==false)
    {
    var jmbmc=crmForm.all.new_pricelevel_kzid.DataValue[0].name;
    
    
    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>new_pricelevel_kz</q1:EntityName>" + 
    "        <q1:ColumnSet xsi:type=\"q1:ColumnSet\">" + 
    "          <q1:Attributes>" + 
    "            <q1:Attribute>new_pricelevel</q1:Attribute>" + 
    "          </q1:Attributes>" + 
    "        </q1:ColumnSet>" + 
    "        <q1:Attributes>" + 
    "          <q1:Attribute>new_name</q1:Attribute>" + 
    "        </q1:Attributes>" + 
    "        <q1:Values>" + 
    "          <q1:Value xsi:type=\"xsd:string\">"+jmbmc+"</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;
    
    
    try
    {
    var id   =resultXml.getElementsByTagName("q1:new_pricelevel")[0].childNodes[0].nodeValue;
    var mc =resultXml.getElementsByTagName("q1:new_pricelevel")[0].getAttribute("name");
    
    var lookupData = new Array();
    //Create an Object add to the array.
       var lookupItem= new Object();
    //Set the id, typename, and name properties to the object.
       lookupItem.id = id;
       lookupItem.typename = 'pricelevel';
       lookupItem.name = mc;
    // Add the object to the array.
       lookupData[0] = lookupItem;
    // Set the value of the lookup field to the value of the array.
       crmForm.all.pricelevelid.DataValue = lookupData;
    
    //开始
    
    try
    {
    	
    
    	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>productpricelevel</q1:EntityName>" + 
    	"        <q1:ColumnSet xsi:type=\"q1:AllColumns\" />" + 
    	"        <q1:Distinct>false</q1:Distinct>" + 
    	"        <q1:Criteria>" + 
    	"          <q1:FilterOperator>And</q1:FilterOperator>" + 
    	"          <q1:Conditions>" + 
    	"            <q1:Condition>" + 
    	"              <q1:AttributeName>pricelevelid</q1:AttributeName>" + 
    	"              <q1:Operator>Equal</q1:Operator>" + 
    	"              <q1:Values>" + 
    	"                <q1:Value xsi:type=\"xsd:string\">"+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);
    	try{
    	var resultXml = xmlHttpRequest.responseXML;
    
    	//总金额
    	var amount= resultXml.getElementsByTagName("q1:amount")[0].childNodes[0].nodeValue;
    	crmForm.all.totalamount.DataValue=Number(amount);
    
    	}
    	catch(Exception){
    
    	}
    	
    	var xml2 = "" + 
    	"<?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_pricelevel_kz</q1:EntityName>" + 
    	"        <q1:ColumnSet xsi:type=\"q1:AllColumns\" />" + 
    	"        <q1:Distinct>false</q1:Distinct>" + 
    	"        <q1:Criteria>" + 
    	"          <q1:FilterOperator>And</q1:FilterOperator>" + 
    	"          <q1:Conditions>" + 
    	"            <q1:Condition>" + 
    	"              <q1:AttributeName>new_pricelevel</q1:AttributeName>" + 
    	"              <q1:Operator>Equal</q1:Operator>" + 
    	"              <q1:Values>" + 
    	"                <q1:Value xsi:type=\"xsd:string\">"+id+"</q1:Value>" + 
    	"              </q1:Values>" + 
    	"            </q1:Condition>" + 
    	"          </q1:Conditions>" + 
    	"        </q1:Criteria>" + 
    	"      </query>" + 
    	"    </RetrieveMultiple>" + 
    	"  </soap:Body>" + 
    	"</soap:Envelope>" + 
    	"";
    
    	var xmlHttpRequest2 = new ActiveXObject("Msxml2.XMLHTTP");
    
    	xmlHttpRequest2.Open("POST", "/mscrmservices/2007/CrmService.asmx", false);
    	xmlHttpRequest2.setRequestHeader("SOAPAction","http://schemas.microsoft.com/crm/2007/WebServices/RetrieveMultiple");
    	xmlHttpRequest2.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
    	xmlHttpRequest2.setRequestHeader("Content-Length", xml2.length);
    	xmlHttpRequest2.send(xml2);
    	try{
    	var resultXml2 = xmlHttpRequest2.responseXML;
                     var jf= resultXml2.getElementsByTagName("q1:new_jmbjf")[0].childNodes[0].nodeValue;
    	//本次积分
    	crmForm.all.new_bcjf.DataValue=Number(jf);
    
    	}
    	catch(Exception){
                    crmForm.all.new_bcjf.DataValue=Number(0);
    
    	}
    
    
    }
    catch (Exception)
    {
    }
    
    //结束
    }
    catch (Exception)
    {
    }
    
    }
    
  • 相关阅读:
    mysql主从延迟高的原因
    OpenStack云平台网络模式及其工作机制
    maps.reg
    dnion的remap.conf文件
    linux的tar命令
    traffic server文件目录
    records.config文件参数解释
    VNC配置
    KVM详情
    cache.config文件配置模板
  • 原文地址:https://www.cnblogs.com/hellohongfu/p/1763874.html
Copyright © 2011-2022 走看看