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