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

      

  • 相关阅读:
    3月4号—3月20号的计划
    Codeforces Round #344 (Div. 2) D. Messenger kmp水题
    Codeforces Round #344 (Div. 2) C. Report 水题
    整数三分(模板)
    Codeforces Round #344 (Div. 2) E. Product Sum 三分
    hdu3276 Graph and Queries 离线+treap
    bzoj1588: [HNOI2002]营业额统计 treap
    hdu5002 tree LCT
    bzoj2594 [Wc2006]水管局长数据加强版 离线+LCT维护边权
    bzoj2002 弹飞绵羊 LCT
  • 原文地址:https://www.cnblogs.com/hambywu/p/5504072.html
Copyright © 2020-2023  润新知