zoukankan      html  css  js  c++  java
  • CRM中复制记录的方法

    function Copy() {
    
     //step 1 查询当前信息
    
    var new_code = Xrm.Page.getAttribute("new_code").getValue();//促销编号
    var new_name = Xrm.Page.getAttribute("new_name").getValue();//促销名称
    
      var new_ruletypecode = Xrm.Page.getAttribute("new_ruletypecode").getValue();//规则类型    选项集 
    
    //step 2 组合成新的对象
    
    var newRule = new Object();
    newRule.new_code = new_code;
    newRule.new_name = new_name;
    newRule.new_ruletypecode = { Value: new_ruletypecode };  // 选项集 必须使用这种赋值方法,否则就会报错
    
    
    
    //step 3 创建新记录
    var jsonEntity = window.JSON.stringify(newRule);
    var createEntityReq = CreateEntityRecord("new_Entity", false, false);
    createEntityReq.send(jsonEntity);
    if (createEntityReq.readyState == 4 /* complete */) {
    if (createEntityReq.status == 201) {
    
    //做想做的事情
    
    }
    
    }
    
    }
    //创建XMLHttpRequest,创建实体信息
    function CreateEntityRecord(entityschema, syncmode, isvmode) {
    if (typeof (syncmode) == "undefined") {
    syncmode = false;
    }
    if (typeof (isvmode) == "undefined") {
    isvmode = false;
    }
    
    var orguniquename = "";
    if (isvmode) {
    orguniquename = GetGlobalContext().getOrgUniqueName(); //GetGlobalContext function exists in ClientGlobalContext.js.aspx
    } else {
    orguniquename = Xrm.Page.context.getOrgUniqueName();
    }
    
    var serverUrl = "";
    if (location.href.toLowerCase().indexOf(orguniquename.toLowerCase() + ".") > 0) {
    serverUrl = "//" + location.host;
    }
    else {
    serverUrl = "//" + location.host + "/" + orguniquename;
    }
    serverUrl = document.location.protocol + serverUrl;
    var ODataPath = serverUrl + "/XRMServices/2011/OrganizationData.svc" + "/" + entityschema + "Set";
    
    var createEntityReq = new XMLHttpRequest();
    createEntityReq.open("POST", ODataPath, syncmode);
    createEntityReq.setRequestHeader("Accept", "application/json");
    createEntityReq.setRequestHeader("Content-Type", "application/json; charset=utf-8");
    return createEntityReq;
    }
    
     

      

  • 相关阅读:
    SpringCloud组件
    Lambda遍历Map集合
    转换为base64格式
    控制器注解参数判空
    SpringBoot项目使用环境变量当做端口号
    使用控制台占位符输出日志, 使用占位符Plus
    Java 传无限参数
    将yyyy-MM-dd hh:mm:ss转换为时间戳
    HTML使用svg,定义.svg格式
    演示js异步,同步请求,响应解码
  • 原文地址:https://www.cnblogs.com/hambywu/p/5504072.html
Copyright © 2011-2022 走看看