views:

47

answers:

1

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?

A: 

You are correct that you are using the Advanced Developer Extensions for MS CRM 4.0 in your code and it will not work on 3.0.

There are a number of ways to accomplish this in MS CRM 3.0.

  1. You could use a Callout assembly when the entity or related entity is created or updated.

  2. You could use a custom workflow when the entity or related entity is created or updated.

  3. You could create a scheduled application to fill these fields.

  4. You could call the CRM webservices from JavaScript in the form to find those fields.

What isn't clear to me is how these entities are related. Are they 1:N or N:1

Mark Kovalcson