Quantcast
Channel: Microsoft Dynamics CRM
Viewing all articles
Browse latest Browse all 123975

Forum Post: Populate Lookup Field Based on the other Lookup Field Value

$
0
0

Hello Everyone!

I am trying to Populate a Lookup value on the Opportunity Product fort with Unit of Measure but running into the problem. The Error says 

function getVal() {

if (Xrm.Page.getAttribute("productid").getValue() != null && Xrm.Page.getAttribute("uofmid").getValue() == null){

var lookupItem = new Array;
lookupItem = Xrm.Page.getAttribute("productid").getValue();
var id = lookupItem[0].id;
//var odataSetName = "productSet";
retrieveRecord(id, "ProductSet", querySuccess, queryFailure);

function querySuccess(data, textStatus, XmlHttpRequest) {
var myArray = new Array();

if (data.DefaultUoMId!= "") {
var jsonObject = { "entityType": "product",
"id": data.DefaultUoMId.Id,
"name": data.DefaultUoMId.Name
};
myArray[0] = jsonObject;
Xrm.Page.data.entity.attributes.get("uofmid").setValue(myArray);
}
}
}
function queryFailure(XMLHttpRequest, textStatus, errorThrown) {
alert("Error : " + textStatus + ": " + JSON.parse(XMLHttpRequest.responseText).error.message.value);
}
}


Viewing all articles
Browse latest Browse all 123975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>