You need to sign in to do that
Don't have an account?
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());
}