function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

New Customer Object cannot be casted to subclass of SObject

Hi there,
we have setup a new customer object class (let's call it NewCustomerObject__c) in our sandbox. After that we created a couple of instances of this object by using.
I wrote JAVA class that performs a simple query: (SELECT  Attribute__c from NewCustomerObject__c).
When iterating over the results

private void queryTest() {

String queryString = "SELECT id FROM NewCustomerObject__c";

List results = Functions.executeQuery(queryString);

Iterator it = results.iterator();

while (it.hasNext()) {

SObject newObject = (SObject);

System.out.println("Class : " + newObject.getClass());



The method getClass() returns com.sforce.soap.enterprise.sobject.SObject.

I can't cast newObject to no other class but SObject either.

NewCustomerObject newObject = (NewCustomerObject); fails.

If I run the same method after replacing NewCustomerObject__c with a customer object that had been setup up earlier in the enterprise portal. => And had been copied into the sandbox, the getClass() method returns com.sforce.soap.enterprise.sobject.CustomerObject__c. In that case the class cast works, too.

What can I do to fix this?


Maybe that helps to solve my problem:
binding.describeSObjects(new String[] {"NewCustomerObject__c"});   throws InvalidSObjectFault.
I have set up another customer object in the sandbox, with the same result. It only works with customer objects which already existed in the productive environment.
I'd like to know if other customers have made similar expiriences before with their sandboxes.
Have you downloaded and imported the new WSDL?

Hi Simon,

done that. Just to be sure I've download the wsdl once again.

I've checked that the java class has been imported into the com.sforce.soap.enterprise.sobject package and that defines my customer object.

The describeGlobals() method returns the customer object with all the needed attributes exists. (However, I don't know where the method gets that information from.)

The object also behaves as it should when you work with it in the web client. It's seems to me that the SOAP message says "Hi, there comes an (unspecified) sobject...", when it should say "it's a NewCustomerObject."

Know what I mean?