0

Hi I have an aura enabled method that returns a Cycle Record, The issue is some of the fields are returning null in the aura enabled method compared to querying in execute anonymous and workbench.

This is my Code

    @AuraEnabled
public static PC_Roche_Cycle__c getCycleRecord(Id cycleRecordId){

    PC_Roche_Cycle__c cycleRecord = [SELECT Id, Name, PC_Roche_Cycle_Actual_Date__c, PC_Roche_Program_Coverage__r.PC_Roche_Scheme__r.Name,
                                    PC_Roche_Program_Coverage__r.PC_Roche_Scheme__r.PC_Roche_Dosage_Fixed__c,PC_Roche_Brand_1_Lookup__r.Name,
                                    PC_Roche_Program_Coverage__r.PC_Roche_Scheme__r.PC_Roche_Descriptor__c, PC_Roche_Free_Dosage_Brand_1__c,
                                    PC_Roche_Program_Coverage__r.PC_Roche_Scheme__r.PC_Roche_Scheme_Code__c,
                                    PC_Roche_Brand_2_Lookup__c, PC_Roche_Free_Dosage_Brand_2__c
                                    FROM PC_Roche_Cycle__c
                                    WHERE ID =: cycleRecordId];

    System.debug('SCHEME>>>>>>' + cycleRecord.PC_Roche_Program_Coverage__r.PC_Roche_Scheme__c);
    System.debug('SCHEME NAME>>>>>' + cycleRecord.PC_Roche_Program_Coverage__r.PC_Roche_Scheme__r.Name);
    System.debug('dosage fixed>>>>>>'+cycleRecord.PC_Roche_Program_Coverage__r.PC_Roche_Scheme__r.PC_Roche_Dosage_Fixed__c);
    System.debug('Descriptor>>>>>'+cycleRecord.PC_Roche_Program_Coverage__r.PC_Roche_Scheme__r.PC_Roche_Descriptor__c);
    System.debug('CYCLE>>>>>>' + cycleRecord.Id);
    System.debug('CYCLERECORDID>>>>>' + cycleRecordId);
    System.debug('SCHEME CODE>>>>>' + cycleRecord.PC_Roche_Program_Coverage__r.PC_Roche_Scheme__r.PC_Roche_Scheme_Code__c);

    return cycleRecord;
}

The fields cycleRecord.PC_Roche_Program_Coverage__r.PC_Roche_Scheme__r.PC_Roche_Scheme_Code__c AND cycleRecord.PC_Roche_Program_Coverage__r.PC_Roche_Scheme__r.PC_Roche_Descriptor__c AND cycleRecord.PC_Roche_Program_Coverage__r.PC_Roche_Scheme__r.PC_Roche_Descriptor__c

are returning null, but when I try to use my query in execute anonymous and workbench with the ID being passed in the parameter, I am getting a correct result.

I'm confused with what's wrong with this, or it's just that I'm missing out something in regards to aura enabled methods.

Any advice will do, thank you.

  • You are using the same user for both queries? – Christian Szandor Knapp Feb 6 at 12:13
  • I missed that one! I'll check it if the user accessing the query has a permission for this fields. Thanks! – imajmdf Feb 6 at 12:28

Your Answer

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

Browse other questions tagged or ask your own question.