I'm trying to receive data from a variable I've declared outside the two functions I'm working with.
var AccountOwnerId;
function checkUserContact() {
var lookup = new Array();
lookup = Xrm.Page.getAttribute("pp_qcustomerid").getValue();
if (lookup != null) {
var name = lookup[0].name;
var id = lookup[0].id.substring(1, 37);
var entityType = lookup[0].entityType;
}
var res = retrieveRecord(id, "AccountSet", UserRetrievedSuccess, UserRetrievedError, "OwnerId");
alert(AccountOwnerId);
}
function UserRetrievedSuccess(data, textStatus, XmlHttpRequest) {
AccountOwnerId = data.OwnerId.Id;
alert(AccountOwnerId);
return AccountOwnerId;
}
The alert box in "UserRet.". gets the correct value, but the alert in "checkUs.." gets "UNDEFINED".
Been trying different ways to solve this, but all results in the same problem. So I'm out of ideas.