zoukankan      html  css  js  c++  java
  • [转]Mscrm js异步获取部门名称

    /*****************************************************************************
    '功        能:获取当前用户ID
    '创   建   人:关中刀客
    '创 建  时 间:2007年9月1日
    '使用方法:把本代码copy到任何实体的onload事件中
    *****************************************************************************/
    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\">" +
    "  <soap:Body>" +
    "    <query xmlns:q1=\"http://schemas.microsoft.com/crm/2006/Query\" xsi:type=\"q1:QueryExpression\" xmlns=\"http://schemas.microsoft.com/crm/2006/WebServices\">" +
    "      <q1:EntityName>systemuser</q1:EntityName>" +
    "      <q1:ColumnSet xsi:type=\"q1:ColumnSet\">" +
    "        <q1:Attributes>" +
    "          <q1:Attribute>systemuserid</q1:Attribute>" +
    "          <q1:Attribute>businessunitid</q1:Attribute>" +
    "        </q1:Attributes>" +
    "      </q1:ColumnSet>" +
    "      <q1:Distinct>false</q1:Distinct>" +
    "      <q1:Criteria>" +
    "        <q1:FilterOperator>And</q1:FilterOperator>" +
    "        <q1:Conditions>" +
    "          <q1:Condition>" +
    "            <q1:AttributeName>systemuserid</q1:AttributeName>" +
    "            <q1:Operator>EqualUserId</q1:Operator>" +
    "          </q1:Condition>" +
    "        </q1:Conditions>" +
    "      </q1:Criteria>" +
    "    </query>" +
    "  </soap:Body>" +
    "</soap:Envelope>" +"";

    var xmlHttpRequest = new ActiveXObject("Msxml2.XMLHTTP");

    xmlHttpRequest.Open("POST", "/mscrmservices/2006/CrmService.asmx", false);
    xmlHttpRequest.setRequestHeader("SOAPAction","http://schemas.microsoft.com/crm/2006/WebServices/RetrieveMultiple");
    xmlHttpRequest.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
    xmlHttpRequest.setRequestHeader("Content-Length", xml.length);
    xmlHttpRequest.send(xml);

    var doc = xmlHttpRequest.responseXML;
    var user = doc.selectSingleNode("//BusinessEntity");

    var userbId = user.selectSingleNode("businessunitid").text;

    var xmlbu = "" +
    "<?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\">" +
    "  <soap:Body>" +
    "    <entityName xmlns=\"http://schemas.microsoft.com/crm/2006/WebServices\">businessunit</entityName>" +
    "    <id xmlns=\"http://schemas.microsoft.com/crm/2006/WebServices\">"+userbId.replace("{","").replace("}","")+"</id>" +
    "    <columnSet xmlns:q1=\"http://schemas.microsoft.com/crm/2006/Query\" xsi:type=\"q1:ColumnSet\" xmlns=\"http://schemas.microsoft.com/crm/2006/WebServices\">" +
    "      <q1:Attributes>" +
    "        <q1:Attribute>name</q1:Attribute>" +
    "      </q1:Attributes>" +
    "    </columnSet>" +
    "  </soap:Body>" +
    "</soap:Envelope>" + "";

    var xmlHttpRequest = new ActiveXObject("Msxml2.XMLHTTP");

    xmlHttpRequest.Open("POST", "/mscrmservices/2006/CrmService.asmx", false);
    xmlHttpRequest.setRequestHeader("SOAPAction","http://schemas.microsoft.com/crm/2006/WebServices/Retrieve");
    xmlHttpRequest.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
    xmlHttpRequest.setRequestHeader("Content-Length", xml.length);
    xmlHttpRequest.send(xmlbu);

    var resultXml = xmlHttpRequest.responseXML;
    var bu = resultXml.selectSingleNode("//RetrieveResult");
    var buname = bu.selectSingleNode("name").text;
    alert(buname);
  • 相关阅读:
    输入形如"a-b,b-c,b-d"的字符串,当作相邻路径,计算最远路径
    即时通信软件后端API文档
    Django中,使用redis作为缓存
    Django中,websocket实时通信设置概要
    在Django中,自定义User模型,使用token鉴权,实现注册、登录、修改密码等API
    Django中,用rest_framework写API
    偶尔练习一下,go语言做题目
    关于邮政储蓄卡内钱被盗的思考
    浅谈图片上传之剪切
    JavaScript学习笔记
  • 原文地址:https://www.cnblogs.com/seerlin/p/1885135.html
Copyright © 2011-2022 走看看