+ Start a Discussion
ccracyccracy 

Extending Contact Class

Hi,
 
I am writing a new class (OurContact) that extends the Contact class.
 
When I try to type cast Cotnact object to OurContact object, I get ClassCastException. Please suggest what can be done.
 
Thanks,
Rohit M.
 
Michael SnowMichael Snow
I am very curious to know why you would need to extend the sObject classes.

I may not understand your question correctly, but I think you are trying to take an object of type Contact and cast it to YourContact class.  That would be impossible because the object wasn't instantiated as type YourContact class.  You could take the contact object that you get back from salesforce, and perform a deep copy into an object of YourContact class.  Deep copying would be important if you are using the child relationship SOQL requests.

Rick.BanisterRick.Banister
Use the Partner WSDL It is much better for a flexible data model.