Hi,
You can migrate your record with the GUID or you can simply use following code on the form load to set the lookup based on the account name
function GetAccountBasedOnName()
{
var accountname="Test Account";
var req = new XMLHttpRequest();
req.open("GET", Xrm.Page.context.getClientUrl() + "/api/data/v8.2/accounts?$select=accountid&$filter=name eq '+accountname+"'", true);
req.setRequestHeader("OData-MaxVersion", "4.0");
req.setRequestHeader("OData-Version", "4.0");
req.setRequestHeader("Accept", "application/json");
req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
req.setRequestHeader("Prefer", "odata.include-annotations=\"*\"");
req.onreadystatechange = function() {
if (this.readyState === 4) {
req.onreadystatechange = null;
if (this.status === 200) {
var results = JSON.parse(this.response);
for (var i = 0; i < results.value.length; i++) {
var accountid = results.value[i]["accountid"];
var lookupValue = new Array();
lookupValue[0] = new Object();
lookupValue[0].id = accountid ;
lookupValue[0].name = accountname;
lookupValue[0].entityType = "account";
Xrm.Page.getAttribute("FieldName").setValue(lookupValue);
} else {
Xrm.Utility.alertDialog(this.statusText);
}
}
};
req.send();
}