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

Retrieving the value of a custom field using Partner API

QueryResult qr = binding.query("select Name, Money__c from account");
SObject account = qr.getRecords()[0];
MessageElement[] fields = account.get_any();

Using this code only 1 field ("Name") is returned. How do get the value of my custom field ("Money__c") using the partner API?



Hi WhizA,

I hop I'm not being obvious here, but, fields[0] will always return only the 0th element of the fields array.  How about trying

for (int i=0;i<fields.length;i++) {





Hey Dave,

I saw that in the examples, but my problem is fields.length = 1 when I'm selecting from 2 fields. Any ideas?


Hi WhizA,

So, what is happening is that axis is filtering out values that are nil.  If you capture the SOAP response, you will see your custom field in the message and it will look something like this:

                  <ns5:Id xmlns:ns5="">00330000001oAFIAA2</ns5:Id>    
                  <ns6:LastName xmlns:ns6="">Blow</ns6:LastName>    
                  <ns7:FirstName xmlns:ns7="">Joe</ns7:FirstName>    
                  <ns8:Test__c xsi:nil="true" xmlns:ns8=""/>   
Assuming my FirstName and LastName fields have values, the any array will have a length of 2.

Compare to this response fragment:

                  <ns9:Id xmlns:ns9="">00330000001oAFJAA2</ns9:Id>    
                  <ns10:LastName xmlns:ns10="">Blow</ns10:LastName>    
                  <ns11:FirstName xmlns:ns11="">Joe</ns11:FirstName>    
                  <ns12:Test__c xmlns:ns12="">One</ns12:Test__c>   
Making the same assumptions, the any array for this record will have a length of 3.

There may or may not be a configuration setting to tell Axis not to exclude nulls (nils) from the serialized object.