Please wait, loading...

 

ODATA : get and set value from one entity to another (On change of look up) USING ODATA JAVASCRIPT IN MSCRM 2011 , 2013

February 14, 2014

function employeeonchange() {
    //debugger;
    //alert(‘hi’);
    var lookup = new Array();
    lookup = Xrm.Page.getAttribute(“new_employeename”).getValue();
    if (lookup != null) {
        var name = lookup[0].name;
        var id=lookup[0].id;
    }

   //alert(name);
    oDataSelect = “http://192.168.1.96/zElite/xrmservices/2011/OrganizationData.svc/new_employeeSet?$select=new_EmployeeCode,new_name”;

    $.ajax({
        type: “GET”,
        contentType: “application/json; charset=utf-8”,
        datatype: “json”,
        url: oDataSelect,
        beforeSend: function (XMLHttpRequest) { XMLHttpRequest.setRequestHeader(“Accept”, “application/json”); },
        success: function (data, textStatus, XmlHttpRequest) {
            ProcessReturnedEntity(data.d.results);
           
        },
        error: function (xmlHttpRequest, textStatus, errorThrown) {
            alert(“Status: ” + textStatus + “; ErrorThrown: ” + errorThrown);
        }
    });
    function ProcessReturnedEntity(OneEntity) {
  
        for (var i = 0; i <= 100000; i++) {
            var oneEntity = OneEntity[i];
            names = oneEntity.new_name;
       //   alert(names);
            if (name == names) {
                var code = oneEntity.new_EmployeeCode;
                Xrm.Page.getAttribute(“new_employeecode”).setValue(code);
              //  alert(names);
            }
        }

    }

}

SOURCE : JUST2CODE.IN
Subscribe to our YouTube channel : https://www.youtube.com/user/TheRussell2012 

https://i0.wp.com/microsoftdynamics.in/wp-content/uploads/2020/04/Microsoftdynamics365.png?fit=640%2C651
Microsoft Dynamics Community Profile

Learn more