I've got a few situations where my select string for a retrieveMultipleRecords call contains filters that include lookups (entity references). An example is below which contains 3 lookups in one filter. For example, I have the GUID for a Price Level, and I want in my filter for the field PriceLevelId to equal that GUID. But you cannot set PriceLevelId = theGUID because PriceLevelId is an entity reference (or object). But you can theoretically get that object's Id with PriceLevelId.Id. But neither works. What am I missing? Is there a way to accomplish the goal of this code below? (For clarity, the error is in the selectString declaration).
function getPrice2() { //currently not working
var pricelevelid = Xrm.Page.getAttribute("pricelistid").getValue()[0].id;
var uomid = Xrm.Page.getAttribute("unitid").getValue()[0].id;
var productid = Xrm.Page.getAttribute("productid").getValue()[0].id;
var priceInfo = null;
if ((pricelevelid != null) && (uomid != null) && (productid != null)) {
var selectString = "$select=Amount,ProductPriceLevelId&$filter=(PriceLevelId.Id eq guid'" + pricelevelid + "') and (UoMId eq guid.Id'" + uomid + "') and (ProductId.Id eq
guid'" + productid + "')";
SDK.REST.retrieveMultipleRecords
(
"ProductPriceLevel",
selectString,
function (results) {
if (results != null && results[0] != null) {
priceInfo = results[0];
}
},
function (error) {
alert("getPrice Error: " + error.message);
},
function () { },
false
);
}
if (priceInfo) {
return priceInfo.Amount;
}
else {
return 0;
}
}
Mark Rockwell