We have a situation where we need to grab associated fields from a filtered lookup. We're willing to use javascript in conjunction with with either odata, soap or fetchxml. The goal is to bring in numbers from a custom entity and then fill in
fields to do mathematical calculations.
Basically on change of a lookup, you grab data, put it on the form, then perform the calculations.
Here is how the code used to work. How would you achieve the objective in 2013?
function Literature1_onchange()
{
if (crmForm.all.ftgbase_literature1id.DataValue != null)
{
crmForm.all.ftgbase_quantity1.DataValue = 11;
crmForm.all.ftgbase_total1.DataValue = null;
var idToFetch = crmForm.all.ftgbase_literature1id.DataValue[0].id+
"" ;
//Create AJAX request
var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
xmlhttp.onreadystatechange = function() {
//A value of 4 indicates that the response has been returned
successfully
if (xmlhttp.readyState == 4) {
strXML = xmlhttp.responseText;
var bundleQty = ReturnValueFromXML
(strXML,'BundleQuantity');
var maxQty = ReturnValueFromXML(strXML,'MaxOrderQty');
if (maxQty != null && maxQty != "null"){
crmForm.all.ftgbase_litmax1.DataValue = parseInt
(maxQty) ;
}else{
crmForm.all.ftgbase_litmax1.DataValue = null;
}
if (bundleQty != null && bundleQty != "null"){
crmForm.all.ftgbase_bundlequantity1.DataValue =
parseInt(bundleQty) ;
}else{
crmForm.all.ftgbase_bundlequantity1.DataValue = null;
}
}
}
GetRecordXML(xmlhttp, UserInfo._orgId, 'GetLiterature', idToFetch,
'GetLiterature', idToFetch );
}
else
{
crmForm.all.ftgbase_bundlequantity1.DataValue = null;
crmForm.all.ftgbase_total1.DataValue = null;
crmForm.all.ftgbase_quantity1.DataValue = 11;
}
}
We're willing to either get a method working similar to this or go another route, but not a fetchxml grid, we need to preserve historical data.