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
ClintPClintP 

API 2.5 Query Custom Field

Using the 2.5 API I'm attempting to query using the following command-

qr = sfService.query("select caseNumber, cf_00N30000000ce21 from Case where status = 'New'")

I get an error that cf_00n30000000ce21 is an invalid field. Note the error returns a lower case 'n' instead of the upper case 'N' I sent.

Is this N somehow being converted to lower case or do I have a different problem?  Anyone seen this before?

Thanks

-Clint

benjasikbenjasik
Try the name of the field with a __c apended to it.

If your field name was my_custom_quote, it would be:

select my_custom_quote__c from Case ...
DevAngelDevAngel

Hi ClintP,

Check the describe call for you custom field.  In 2.5 there is an actual name for your custom fields.  You could also check in the app to see what the name of your custom field is now.  Typically, it's a variation of the label, so that if the label for your custom field read Customer Reference the new custom field name would be Customer_Reference and the api would expect Customer_Reference__c.

ClintPClintP

I'm sure that's probably the issue.  Without using the describer I attempted to rename the fields to what I thought they would be (Agents_Affected__c) but that didn't work.

The describer I have must be for 2.0 because I only see the old "cf_" names and not the new names. Can someone point me in the direction of a 2.5 describer app or source code?

Thanks again,

-Clint

DevAngelDevAngel

Hi ClintP

Are you in java or .Net?  If java and jbuilder I have a plugin that will work for you.  If .Net you can download the .Net toolkit for sforce from this site.

Just to verify without going to the trouble of a describer, login to the app and check the custom field definition on your object.

zer0frequencyzer0frequency

Hi  all,

I 've a similar problem.  I am using 2.5 API and when I do describe - I get the correct field name (i.e. with a __c appended to the name. But when I try to retreive the field, I get a bad field exception.

I am working on the contact table and trying to retreive the custom field mailingState__c  which does show in the describe call.

I suspect the automatically generated file Contact.java (extended from sobject) - which doesn't seem to have this custom field and therefore causes the error.

Any ideas?

If I am correct about the Contact.java - can someone help me about how to regenerate those files from the wdsl file? Sorry for asking a possibly-trivial question ??

AxisFault

 faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException

 faultSubcode:

 faultString: org.xml.sax.SAXException: Invalid element in com.sforce.soap.enterprise.sobject.Contact - MailingState__c

 faultActor:

 faultNode:

 faultDetail:

 {http://xml.apache.org/axis/}stackTrace: org.xml.sax.SAXException: Invalid element in com.sforce.soap.enterprise.sobject.Contact - MailingState__c

 at org.apache.axis.encoding.ser.BeanDeserializer.onStartChild(BeanDeserializer.java:260)

 at org.apache.axis.encoding.DeserializationContextImpl.startElement(DeserializationContextImpl.java:963)

 at org.apache.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.java:198)

 at org.apache.axis.message.MessageElement.publishToHandler(MessageElement.java:722)

 at org.apache.axis.message.RPCElement.deserialize(RPCElement.java:233)

 at org.apache.axis.message.RPCElement.getParams(RPCElement.java:347)

 at org.apache.axis.client.Call.invoke(Call.java:2272)

 at org.apache.axis.client.Call.invoke(Call.java:2171)

 at org.apache.axis.client.Call.invoke(Call.java:1691)

 at com.sforce.soap.enterprise.SoapBindingStub.query(SoapBindingStub.java:1273)

 at com.salesforce.samples.Samples.querySample(Samples.java:481)

 at com.salesforce.samples.Samples.run(Samples.java:1097)

 at com.salesforce.samples.Samples.main(Samples.java:43)

 

 

org.xml.sax.SAXException: Invalid element in com.sforce.soap.enterprise.sobject.Contact - MailingState__c

 at org.apache.axis.AxisFault.makeFault(AxisFault.java:129)

 at org.apache.axis.client.Call.invoke(Call.java:2275)

 at org.apache.axis.client.Call.invoke(Call.java:2171)

 at org.apache.axis.client.Call.invoke(Call.java:1691)

 at com.sforce.soap.enterprise.SoapBindingStub.query(SoapBindingStub.java:1273)

 at com.salesforce.samples.Samples.querySample(Samples.java:481)

 at com.salesforce.samples.Samples.run(Samples.java:1097)

 at com.salesforce.samples.Samples.main(Samples.java:43)

Caused by: org.xml.sax.SAXException: Invalid element in com.sforce.soap.enterprise.sobject.Contact - MailingState__c

 at org.apache.axis.encoding.ser.BeanDeserializer.onStartChild(BeanDeserializer.java:260)

 at org.apache.axis.encoding.DeserializationContextImpl.startElement(DeserializationContextImpl.java:963)

 at org.apache.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.java:198)

 at org.apache.axis.message.MessageElement.publishToHandler(MessageElement.java:722)

 at org.apache.axis.message.RPCElement.deserialize(RPCElement.java:233)

 at org.apache.axis.message.RPCElement.getParams(RPCElement.java:347)

 at org.apache.axis.client.Call.invoke(Call.java:2272)

adamgadamg
Re-downloading the WSDL file from the setup area will force it to be regenerated.  (After regenerating the WSDL, you'll need to regenerate the assosiated proxies.  See the getting starting section of the doc for details.)