• 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)
    {
    }
    
    }
    
  • 相关阅读:
    JQuery 绑定单击事件到某个函数的的方法
    一刻校园足球管理平台亮相安徽打造智慧足球解决方案
    jQuery 获取不到 kindeditor 内容 的解决方法
    【视频】 ASP.NET MVC5&微信公众平台整合开发实战
    Set authorization for a whole area
    生成Area URL链接
    在ASP.NET MVC5应用程序中快速接入QQ和新浪微博OAuth
    IOS 监听通讯录是否改变
    ios 读取通讯录数据
    iOS中assign、copy 、retain等关键字的含义
  • 原文地址:https://www.cnblogs.com/hellohongfu/p/1763874.html
Copyright © 2020-2023  润新知