0

I may be missing some silly thing here:

I am getting only partial data from Apex, which means only id and name fields, the rest of the data does not appear in the console. any reason?

SOQL:

public with sharing class ApplicationData {
    @AuraEnabled(cacheable=true)
    public static List<TargetX_SRMb__Application__c> getApplicationsData(String contactId, String type) {
        Contact contact=getMostRecentApplication( contactId );
        System.debug('type: '+type);
        if(type=='Most Recent Application'){
            return [SELECT Id, Name,(Select Id ,Name,TargetX_Reader__Status__c,TargetX_Reader__Date_Due__c from TargetX_Reader__Admissions_Reviews__r) from TargetX_SRMb__Application__c  WHERE Id=:contact.Most_Recent_Application__c];
        }else{
            return [SELECT Id, Name,(Select Id ,Name,TargetX_Reader__Status__c,TargetX_Reader__Date_Due__c from TargetX_Reader__Admissions_Reviews__r) from TargetX_SRMb__Application__c  WHERE TargetX_SRMb__Contact__c=:contactId AND Id!=:contact.Most_Recent_Application__c];
        }
    }

    private static Contact getMostRecentApplication(String contactId){
        return [SELECT Id,Name,Most_Recent_Application__c FROM Contact WHERE Id=:contactId];
    }
}

Wire Method:

@wire(getApplicationData, { contactId: "$recordId", type: "$apptypes" })
  wiredApplications({ error, data }) {
    if (data) {
      this.applications = data;
      console.log("data From Apex: " + JSON.stringify(data));
    } else if (error) {
      this.error = error;
    }
  }

Result in LWC:

enter image description here

2
  • Have you confirmed TargetX_Reader__Status__c and TargetX_Reader__Date_Due__c are populated on those TargetX_Reader__Admissions_Reviews__r records? Jan 29, 2021 at 0:39
  • @MatthewSouther: you are right, I was so silly about this. Thank you.
    – Ajay
    Jan 29, 2021 at 0:55

1 Answer 1

1

Based on the conversation above, I'm confirming here that unpopulated fields don't show up in the JavaScript object's properties when you get data from an Apex query in LWC.

1
  • Yeah, thank you. Now I remember.
    – Ajay
    Jan 29, 2021 at 1:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .