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);
  • 相关阅读:
    CentOS7 64位下MySQL5.7安装与配置
    Linux CentOS7.0下JAVA安装和配置环境变量
    在MySQL中使用explain查询SQL的执行计划
    ionic3中使用自定义配置
    RabbitMQ发布订阅实战-实现延时重试队列
    springboot 项目mybatis plus 设置 jdbcTypeForNull (oracle数据库需配置JdbcType.NULL, 默认是Other)
    Python之Mysql及SQLAlchemy操作总结
    数据库分库分表思路
    RPC框架实践之:Apache Thrift
    vue使用watch 观察路由变化,重新获取内容
  • 原文地址:https://www.cnblogs.com/janmson/p/1434746.html
Copyright © 2011-2022 走看看