开发者

Pull data from another entity in CRM 3.0?

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(r开发者_运维问答esult[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?


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


I used to have a similar problem, as said by Mark, you are using classes into CRM 4 and over, developed by XRM community.

In your case I would use the raw call of web service with XMLHTTP as shown in this articles.

http://blog.customereffective.com/blog/2008/02/calling-the-crm.html

http://ayazahmad.wordpress.com/2006/12/14/calling-custom-web-services-through-mscrm-30-form-a-way-to-duplicate-detection/

First is for calling CRM services, and I think the example explained on it, is from a CRM 3.0. In the other hand, the second link only talks about calling a web service from javascript, the process is the same as for calling CRM web service, the only you have to change is the endpoint URL.

The way to do it is to build the SOAP envelope manually. I remember there were some javascript library to do fetches, creates, updates... from javascript to CRM, but don't remember where is it, and I think it was done for CRM 4.0, anyway I'm going to search it and post it here.

See you

EDIT:

This link has some information about what I explained:

https://community.dynamics.com/product/crm/crmtechnical/b/crmdelvingintodynamics/archive/2008/07/11/a-microsoft-dynamics-crm-javascript-sdk.aspx

Ascentium used to have the CRM SDK for javascript in their web, but most of the link now available send to an Avanade blog, so it's a nice place to find for some more new information.

http://blogs.infinite-x.net/2008/07/15/ascentium-crmservice-javascript-library/

http://www.avanadeblog.com/xrm/

But keep an eye on the version it is prepared to.

See you.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜