private class StateInfo {
Account acc {get; set;}
StateInfo(Account acc){
this.acc = acc;
}
Contact cont {get; set;}
StateInfo(Account acc, Contact cont) {
this.acc = acc;
this.cont = cont;
}
}
I am updating this class in my method which is AuraEnabled like this:
Opportunity opp = [Select Id, AccountId From Opportunity Where Id =: oppId];
Child_Service.StateInfo stateInfo = new Child_Service.StateInfo([Select Id, Billing_Account_No__c From Account Where Id =: opp.AccountId]);
Child_Service.StateInfo stateInfo2 = new Child_Service.StateInfo(stateInfo.acc, [Select Id, Email, FirstName, LastName From Contact Where accountId =: stateInfo.acc.ID]);
Continuation con = new Continuation(60);
con.state = stateInfo2;
con.continuationMethod = 'sendEmail';
I am able to access the values of account object in this method, but when I try to access the contact email value in my sendEmail
method which is also AuraEnabled I am not able to get the contact email value,
@AuraEnabled(continuation=true cacheable=true)
public static String sendEmail(Object state){
Child_Service.StateInfo stateInfo = (Child_Service.StateInfo)state;
try {
System.debug('account id: ' + stateInfo.acc.Id);
String email = String.valueOf(stateInfo.cont.email);
System.debug('Email::: ' + email);
} catch(Exception e){
System.debug('Exception occured at: ' + e.getLineNumber() + ' is: ' + e.getMessage());
}
return stateInfo.cont.email;
}
I get 'undefined' response in lightning, is it because I am not setting any parameter for the sendEmail method from lightning controller, or how do I do that.
Also is this the right approach for not querying the object more than once, or should I try to make an object type attribute in my lightning component and then update that and send again to my apex to access the field value as and when required.