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;
    }
    
     

      

  • 相关阅读:
    leetcode Majority Element
    Missing Number 三种解法
    Effective C++学习笔记 chapter 1
    C++ 笔记
    三色排序
    归并排序-就地排序
    506,display有哪些值?说明他们的作用
    505,display,float,position之间的关系(有疑问)
    504,什么是FOUC?怎么避免
    503,display:none;与visibility:hidden;的区别
  • 原文地址:https://www.cnblogs.com/hambywu/p/5504072.html
Copyright © 2011-2022 走看看