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
TaoDuhTaoDuh 

retrieve custom field

I have created a custom field on the Lead object called LegacyId.

This query works fine (Java code):
   SObject[] sObjects = binding.retrieve("Id, FirstName, LastName, City, State, Company, Email, Website", "Lead", new String[] {id});

But this one, not so well (error is down at the bottom):
   SObject[] sObjects = binding.retrieve("Id, FirstName, LastName, City, State, Company, Email, Website, LegacyId__c", "Lead", new String[] {id});

Obviously, trying to figure out why.

Oddly, it used to work until I changed the label on my custom field.  I have since deleted it and created a new one but I'm still stuck with my error.  Note that if I do a describeSObject("Lead") I do see my field name.

When it was working, I was trying to figure out how to get the value out of my result set.  Obviously, there was no method called lead.getLegacyId__c().  I tried to get it via reflection but that didn't work either.  (No surprise there)  But I couldn't find another way.  While I'm asking questions I thought I'd throw that in there.


The error:
[ERROR] Exception:
org.xml.sax.SAXException: Invalid element in com.sforce.soap.enterprise.sobject.Lead - LegacyId__c
    at org.apache.axis.encoding.ser.BeanDeserializer.onStartChild(BeanDeserializer.java:258)
    at org.apache.axis.encoding.DeserializationContext.startElement(DeserializationContext.java:1035)
    at org.apache.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.java:165)
    at org.apache.axis.message.MessageElement.publishToHandler(MessageElement.java:1141)
    at org.apache.axis.message.RPCElement.deserialize(RPCElement.java:236)
    at org.apache.axis.message.RPCElement.getParams(RPCElement.java:384)
    at org.apache.axis.client.Call.invoke(Call.java:2467)
    at org.apache.axis.client.Call.invoke(Call.java:2366)
    at org.apache.axis.client.Call.invoke(Call.java:1812)
    at com.sforce.soap.enterprise.SoapBindingStub.retrieve(SoapBindingStub.java:3309)
    at com.vistage.salesforce.ToddTest.retrieveLead(ToddTest.java:92)
    at com.vistage.salesforce.ToddTest.findRecentUpdates(ToddTest.java:58)
    at com.vistage.salesforce.ToddTest.sfTests(ToddTest.java:38)
    at com.vistage.salesforce.ToddTest.<init>(ToddTest.java:27)
    at com.vistage.salesforce.ToddTest.main(ToddTest.java:212)
An unexpected error has occurred.; nested exception is:
    org.xml.sax.SAXException: Invalid element in com.sforce.soap.enterprise.sobject.Lead - LegacyId__c
AcronymAcronym
You may need to regenerate you client stub.  Download the wsdl again, and the generated stub should have the custom field in your Lead object.
TaoDuhTaoDuh
That did the trick.  Thanks!