none
How to update lookup field in crm 2011

    Domanda

  • This is my test code,I don't know how to write lookup field.

    function testUpdate() {
        var Helper = new DataHelp();
        var entityIdUrl = "new_email_sendSet(guid'E2C2468A-5791-E111-8370-E41F1365704C')";
        var entity = new Object();
        entity.new_name = "testUpdate";

    //??

        var result = Helper.Update(entityIdUrl, JSON.stringify(entity));
        alert("update:" + result.toString());
    }

    DataHelp.prototype.Update = function (_EntityIdUrl, jsondata) {
        var _updateUrl = getWCFUrl(_EntityIdUrl);
        var uptXmlHttpReq = new XMLHttpRequest();
        uptXmlHttpReq.open("POST", _updateUrl, false);
        uptXmlHttpReq.setRequestHeader("Accept", "application/json");
        uptXmlHttpReq.setRequestHeader("Content-Type", "application/json; charset=utf-8");
        uptXmlHttpReq.setRequestHeader("X-HTTP-Method", "MERGE");
        uptXmlHttpReq.send(jsondata);
        if (uptXmlHttpReq.readyState == 4) {
            if (uptXmlHttpReq.status == 204 || uptXmlHttpReq.status == 1223) {
                return true;
            }
            else {
                alert(uptXmlHttpReq.responseText);
                return false;
            }
        }
    }

    mercoledì 30 ottobre 2013 09:37

Risposte

  • OK,I think i find Solution.

    function testUpdate() {

        var Helper = new DataHelp();
        var entityIdUrl = "new_productclassifySet(guid'89D0DF34-E728-E311-B9B7-00155D014A00')";
        var entity = new Object();
        entity.new_classifycode = "07";
        entity.new_relationshipcode = "FI0107";

        var currency = new Object();
        currency.Id = "{83D0DF34-E728-E311-B9B7-00155D014A00}";
        currency.LogicalName = "new_productclassify";
        entity.new_upproductclassify = currency;

        var result = Helper.Update(entityIdUrl, JSON.stringify(entity));
        alert("update:" + result.toString());
    }

    mercoledì 30 ottobre 2013 10:20