0

In SOQL, I am only getting field which are not blank. I want record with the fields of object irrespective of they are null or not. Please refer to below code:

  @AuraEnabled
public static sObject OnloadTab(String id1){
    ProjectObject__c p = [select id,f1__c,f2__c,f3__c from ProjectObject__c where id= :id.valueOf(id1) limit 1];
    system.debug('Record : '+p);
    return p;
}

result :

 ProjectObject__c :{Id=a094C000000HPDBQA4, f1=01250000000ECl4AAG}

where as I want

ProjectObject__c :{Id=a094C000000HPDBQA4, f1=01250000000ECl4AAG,f2='',f3=''}
1

You are actually getting all fields the thingsis Debug log or Developeer console only display those columns whch have any value (To improve readability).

If you use those fields you will not get any exception and if you run them in Query Editior you can see the blank fields as well.

Update As per @Eric's comments if your are getting data from server side and the fields/var are null they are NOT sent to the component....An setting them in the component does not allow you to pass them back to the server....see my troubles here: salesforce.stackexchange.com/questions/156539/…. I needed up creating a class with all the var I needed and explicitly set the nulls to ''.

So I think the best you can do is create class for same and use it.

7
  • I am also getting that record in my lightning controller. And in that also i am getting the same result. only 2 fields Feb 14 '17 at 7:44
  • @Max yes but did you try to access that fields, Are you getting any exception? Feb 14 '17 at 7:47
  • Yes i tried accessing the field. I am not getting any exception Feb 14 '17 at 9:42
  • My requirement is i want those fields which are null in my record in controller. But i am not getting any fields which are null. Feb 14 '17 at 9:43
  • 2
    Unfortunately with lightning, if your are getting data from server side and the fields/var are null they are NOT sent to the component....An setting them in the component does not allow you to pass them back to the server....see my troubles here: salesforce.stackexchange.com/questions/156539/…. I needed up creating a class with all the var I needed and explicitly set the nulls to ''.
    – Eric
    Feb 15 '17 at 16:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.