RE: Getting a Lookup (User) from a text field
try using the retrieve multiple, which you can filter on fields, for example
var req = new XMLHttpRequest();
req.open("GET", Xrm.Page.context.getClientUrl() + "/api/data/v9.1/contacts?$filter=_owninguser_value eq 34b19a0b-ad6e-48fb-968d-77334f5e5dfe", 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 contactid = results.value[i]["contactid"];
}
} else {
Xrm.Utility.alertDialog(this.statusText);
}
}
};
req.send();