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
punit.theikospunit.theikos 

query result returning only not null values

Hi All,

I am trying to fetch all the field values of Account. For this I am creating a query by describing the object and then running the query. The query result is only containing values for not null fields. I am not sure why this would happen. Any clues would be appreciated. The code that I am using is as below:

Thanks

Punit

   DescribeSObjectResult describeAccounts = sfdc.describeSObject("Account");
   Field[] accountFields = describeAccounts.getFields();
   String queryString = "Select ";
   for(int i =0; i<accountFields.length; i++){
    if(!accountFields[i].getName().equalsIgnoreCase("ID")){
     if(i == accountFields.length - 1){
      queryString = queryString + accountFields[i].getName();
     }else{
      queryString = queryString + accountFields[i].getName() + " ,";
     }
    }
   }
   queryString = queryString + " From Account where Id = '" + accountId + "'";
   System.out.println("QUERY IS " + queryString);
   QueryResult accountDetails = binding.query(queryString);
   SObject account =  accountDetails.getRecords()[0];
   for(int i =0; i<accountFields.length; i++){
    System.out.println("Field is :" + accountFields[i].getName());
    System.out.println("Value is :" + account.get_any()[i].getValue());
   }

 

SuperfellSuperfell
Its a bug in Axis 1.1. If you examine the actual SOAP response, you'll see the elements are there, but axis "helpfully" ignores any that are null. THis is almost but not entirely fixed in Axis 1.2. see http://blog.sforce.com/sforce/2005/06/migrating_from_.html