Problems and solutions of CRM concurrency

Source: Internet
Author: User
Tags json timestamp to date

CRM2011 to delete and add operations will be automatically judged, such as a open record x,b also open the record x, then B deleted the record x,a to update the words will be prompted. The update is the latter covering the former, such as a open record x,b open record x, then b update the field Y in record X to 3, then click Save, A to update the field Y to 5 save, and the last 5 will cover 3. The problem with this log is that when a changes to 5 you want to save the prompt record X has been updated at some point in time, if you continue to save will overwrite the record, otherwise discard save.

With JS complete the entire verification, and then register the form of the onload and OnSave to achieve the goal, of course, add jquery and Json2 two JS class library

On JS First

var previousmodificationdateonload;
var ServerURL = Xrm.Page.context.getServerUrl ();
var ServerURL = document.location.protocol + "//" + Document.location.host + "/" + Xrm.Page.context.getOrgUniqueName ();
var odata_endpoint = "/xrmservices/2011/organizationdata.svc";
var RecordID;
var entityname;
    function Getpreviousmodificationdate () {RecordID = Xrm.Page.data.entity.getId (). Replace (' {', '). Replace ('} ', ');
    EntityName = Xrm.Page.data.entity.getEntityName () + "Set";
    Previousmodificationdateonload = new Date (); Retrieverecord (Recordid,entityname, function (data) {previousmodificationdateonload = data.
        ModifiedOn;
    Previousmodificationdateonload = new Date (parseint (/\/date\ (\d+). */.exec (Previousmodificationdateonload) [1]));
    },null, false);
alert (previousmodificationdateonload);
    function Validateconcurrency (executionobj) {if (Xrm.Page.ui.getFormType () ==1) {return; } var previousmodificationdateonsave, previousmodifIedbyonsave; Retrieverecord (Recordid,entityname, function (data) {Previousmodificationdateonsave = data.
        ModifiedOn;
        alert (Previousmodificationdateonsave); Previousmodifiedbyonsave = data.
        Modifiedby.name;
        alert (Previousmodifiedbyonsave); Change timestamp to date format Previousmodificationdateonsave = new Date (parseint/\/date\ (\d+). */.exec (Previ
        Ousmodificationdateonsave) [1])); Alert (previousmodificationdateonload + "\ n" +previousmodificationdateonsave) if (Previousmodificationdateonload &L T Previousmodificationdateonsave) {var continuesave = confirm ("The record is recently modified by" +PR Eviousmodifiedbyonsave+ "on" + Previousmodificationdateonsave + ". If you are chose to save this record you'll overwrite the recent changes made by "+ Previousmodifiedbyonsave
            + "\nare you sure for your want to save this record");
      if (!continuesave) {          Executionobj.geteventargs (). Preventdefault ();
                    
            Event.returnvalue = false;
    }//previousmodificationdateonload = Previousmodificationdateonsave;
},null, false); function Retrieverecord (ID, Odatasetname,successcallback, errorcallback, ASync) {if (Async==null | | async==unde
    Fined) {ASync = true;
    }//alert (ServerURL +odata_endpoint + "/+odatasetname+" (GUID ' +id+ ') "); $.ajax ({type: "Get", ContentType: "Application/json;charset=utf-8", DataType: "JSON", Async: ASync, Url:serverurl +odata_endpoint + "/+odatasetname+" (GUID ' "+id+") ", Beforesend:function (xmlhttpreques
        T) {Xmlhttprequest.setrequestheader ("Accept", "Application/json"); }, Success:function (data,textstatus,xmlhttprequest) {if (successcallback) {SUCCESSCALLB
         ACK (data.d,textstatus,xmlhttprequest);   }, Error:function (Xmlhttprequest,textstatus,errorthrown) {alert ("error");
            if (errorcallback) {errorcallback (Xmlhttprequest,textstatus,errorthrown);
}
        }
    }); }

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.