Microsoft KB Archive/860839

= CRMOpportunity::RetrieveByObject Method Does Not Return Expected Results =

Article ID: 860839

Article Last Modified on 8/5/2005

-

APPLIES TO

 Microsoft Business Solutions CRM Software Development Kit, when used with:  Microsoft CRM 1.2

 Microsoft Business Solutions CRM 1.0 

-



TechKnowledge Content
Issue

What are the expected results when using the RetrieveByObject method.

Notes

There are two primary types of relationships that exist between objects within CRM; Associations and Parent-Child. Association relationships are stored in intersection tables to support one/many-to-many relationships. Parent-Child relationships are stored directly in the base tables using primary-foreign key relationships.

RetrieveByObject returns objects that have Association relationships to another object where the Association was created by using the SetAssociation method.

In the case of CRMOpportunity::RetrieveByObject, it will return all opportunity records from the AccountOpportunities base table where AccountId equals the specified AccountId. However, records are only created in AccountOpportunities when the CRMOpportunity::SetAssocation is invoked. The Microsoft CRM UI does not invoke the SetAssocation method when the Potential Customer field is populated with an account and as such the AccountOpportunities table is not populated.

Resolution

Rather than use CRMOpportunity::RetrieveByObject to retrieve all opportunities that are children of a specified account, use the CRMAccount::RetrieveSubOpportunities or CRMAccount::RetrieveAllOpportunities. (See the Microsoft CRM SDK on MSDN for more details).

Note - This article uses CRMOpportunity::RetrieveByObject as the example but the content can be applied to all objects that have the RetrieveByObject and SetAssociation methods exposed.

This article was TechKnowledge Document ID: 32050

Keywords: kbmbsmigrate KB860839

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.