Microsoft KB Archive/874952

= Error &quot;Invalid Object Type&quot; is returned when using the sample code from the Microsoft Business Solutions CRM Software Development Kit for CRMOpportunityProduct.RetrievebyObject method =

Article ID: 874952

Article Last Modified on 9/7/2006

-

APPLIES TO

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

 Microsoft Business Solutions CRM 1.0  Microsoft Business Solutions CRM 1.0 Microsoft CRM 1.2

-

<div class="resolution_section">

TechKnowledge Content
SUMMARY

The sample code snippets for the CRMOpportunityProduct.RetrieveByObject method in the SDK for Microsoft Business Solutions CRM versions 1.0 and 1.2 read as follows.

Incorrect Code for MSCRM v1.2:

Microsoft.Crm.Platform.Proxy.CObjectName objName = new Microsoft.Crm.Platform.Proxy.CObjectName;

objName.Id = strOpportunityId;

objName.Type = Microsoft.Crm.Platform.Proxy.ObjectType.otOpportunityProduct;

Incorrect Code for MSCRM v1.0:

Microsoft.CRM.Proxy.CObjectName objName = new Microsoft.CRM.Proxy.CObjectName;

objName.Id = strOpportunityId;

objName.Type = Microsoft.CRM.Proxy.ObjectType.otOpportunityProduct;

Since the method retrieves products related to the opportunity object, the object type needs to be set to Opportunity.

Correct Code for MSCRM v1.2:

Microsoft.Crm.Platform.Proxy.CObjectName objName = new Microsoft.Crm.Platform.Proxy.CObjectName;

objName.Id = strOpportunityId;

objName.Type = Microsoft.Crm.Platform.Proxy.ObjectType.otOpportunity;

Correct Code for MSCRM v1.0:

Microsoft.CRM.Proxy.CObjectName objName = new Microsoft.CRM.Proxy.CObjectName;

objName.Id = strOpportunityId;

objName.Type = Microsoft.CRM.Proxy.ObjectType.otOpportunity;

REFERENCES

For more information on CRMopportunityProduct class on MSCRM 1.0 ,visit the following MSDN link:

For more information on CRMopportunityProduct class on MSCRM 1.2 ,visit the following MSDN link:

This article was TechKnowledge Document ID: 35184

Keywords: kbmbsmigrate KB874952

-

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

© Microsoft Corporation. All rights reserved.