I have a form with three fields that I'd like to populate based on three attributes of a different entity. What's the best way to do this? I tried this, based on stuff I found online:
if (crmForm.all.new_name.DataValue == null) { return; }
var sdk = new XrmDataContext(null, null);
var id = crmForm.all.new_name.DataValue[0].id;
var fetchXml = "<fetch mapping=\"logical\"><entity name=\"mag_identificationtype\"><all-attributes /><filter type=\"and\"><condition attribute=\"new_advertisingrate\" operator=\"eq\" value=\"" + id + "\" /></filter></entity></fetch>";
var result = sdk.Fetch(fetchXml);
for (var i = 0; i < result.length; i++) {
crmForm.all.new_mediapaymentplan.DataValue = parseFloat(result[i].attributes["new_mediapaymentplan"]);
}
for (var i = 0; i < result.length; i++) {
crmForm.all.new_yellowpagepayment.DataValue = parseFloat(result[i].attributes["new_fixed_yellowpages_fee"]);
}
for (var i = 0; i < result.length; i++) {
crmForm.all.new_extrapayment.DataValue = parseFloat(result[i].attributes["new_extraadvertisingpayment"]);
}
...but it doesn't work, and I suspect that's because it's designed for 4.0. Is there a way to accomplish this in 3.0, and if so, what is it?