zoukankan      html  css  js  c++  java
  • MSCrm javascript queryByAttribute

     我自已实现的

    function getq1AttributesString(attributes)
    {
       
       
    var strRet="";
       
    for(i=0;i<attributes.length;i++)
      {
        strRet
    +=("<q1:Attribute>"+attributes[i]+"</q1:Attribute>") ;

        
      }
       
    return strRet;
    }

    function getq1AttributesValue(attributes)
    {
       
       
    var strRet="";
       
    for(i=0;i<attributes.length;i++)
      {
        strRet
    +=("<q1:Value xsi:type=\"xsd:string\">"+attributes[i]+"</q1:Value>");

        
      }
       
    return strRet;
    }

    function queryByAttribute(entityName, columnsetAttributes, queryAttributes, queryAttributesValue)
    {
    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>"+entityName+"</q1:EntityName>" + 
    "        <q1:ColumnSet xsi:type=\"q1:ColumnSet\">" + 
    "          <q1:Attributes>" + getq1AttributesString(columnsetAttributes)+ 
    "          </q1:Attributes>" + 
    "        </q1:ColumnSet>" + 
    "        <q1:Attributes>" + getq1AttributesString(queryAttributes)+ 
    "        </q1:Attributes>" + 
    "        <q1:Values>" + getq1AttributesValue(queryAttributesValue) + 
    "        </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;
    return resultXml;
    }
    var queryAttributes=new Array("pricelevelid","productid","uomid");
    var columnsetAttributes=new Array("amount");
    var queryAttributesValue=new Array("02BC5E52-021D-DE11-9A15-000AE42C41EE","75E1AB61-27DE-DD11-9A12-000AE42C41EE","A1278C3F-BBDB-DD11-AB5E-002215572EEF");



    queryByAttribute(
    "productpricelevel",columnsetAttributes,queryAttributes,queryAttributesValue);
  • 相关阅读:
    Charles使用
    将当前项目加入系统变量中
    JVM之gc相关
    jdk安装
    nginx相关
    oracle带输入输出参数存储过程(包括sql分页功能)
    ajax 全局拦载处理,可加密、过滤、筛选、sql防注入处理
    01.Java关键字,常量,变量,数值类型
    01.Java数据结构和多线程
    02.MySQL.存储引擎-事务-隔离级别-锁
  • 原文地址:https://www.cnblogs.com/janmson/p/1434746.html
Copyright © 2011-2022 走看看