You need to sign in to do that
Don't have an account?
New Customer Object cannot be casted to subclass of SObject
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) it.next();
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) it.next(); 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?
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 SoapBindingStub.java 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?