You need to sign in to do that
Don't have an account?
Vinicius Damasceno 1
Action.setCallback not being executed event tabclosed lightning component
I have an issue where in my action.setCallBack is not being run.
When user closes the tab, the component call a function onTabClosed.
onTabClosed : function(component, event, helper) {
var aCaseId = component.get("v.recordId");
console.log('yep');
var action = component.get("c.hasCustomerInteractionOpenA");
action.setParams({aCaseId : aCaseId});
action.setCallback(this, function(response) {
console.log('callBack');
var state = response.getState();
var result = response.getReturnValue();
//console.log('BKO Picklist values ' +JSON.stringify(result));
if (state === "SUCCESS") {
console.log('test1');
component.set("v.checkTab",true); }
else{
console.log('test2');
component.set("v.checkTab",true);
} });
$A.enqueueAction(action);
console.log('yep1'); },
The console.log inside callBack is not being executed. Only the console.log(yep1) and (yep2).
Here is the Apex:
@AuraEnabled public static Boolean hasCustomerInteractionOpen(String aCaseId){
try{
Case lCase = [SELECT AttendanceProtocol__c, Id, Status, AttendanceProtocol__r.LastModifiedDate, AttendanceProtocol__r.vlocity_cmt__Status__c, OwnerId FROM Case WHERE Id =: aCaseId LIMIT 1];
if((String.isNotBlank(lCase.AttendanceProtocol__c)) && (lCase.AttendanceProtocol__r.vlocity_cmt__Status__c != 'Closed') && (lCase.OwnerId == (UserInfo.getUserId()))){
List<Case> lCaseCustomer = [SELECT Id,AttendanceProtocol__c, Status, ClosedDate FROM Case WHERE AttendanceProtocol__c =: lCase.AttendanceProtocol__c ORDER BY ClosedDate DESC];
if((lCaseCustomer[0].Id == lCase.Id) && ((lCase.AttendanceProtocol__r.LastModifiedDate) < (lCaseCustomer[0].ClosedDate))){
System.debug('true'); return true; }
} System.debug('false');
return false;
}catch(Exception e){ System.debug('The following exception has occurred: ' + e.getMessage()); return false; } }
The system.debug is returning in the debugging. So, the apex is being called, returning a value.
But the action.setCallBack is not accessing this value. I'm on it has two days, someone can help me? Really appreciate it.
When user closes the tab, the component call a function onTabClosed.
onTabClosed : function(component, event, helper) {
var aCaseId = component.get("v.recordId");
console.log('yep');
var action = component.get("c.hasCustomerInteractionOpenA");
action.setParams({aCaseId : aCaseId});
action.setCallback(this, function(response) {
console.log('callBack');
var state = response.getState();
var result = response.getReturnValue();
//console.log('BKO Picklist values ' +JSON.stringify(result));
if (state === "SUCCESS") {
console.log('test1');
component.set("v.checkTab",true); }
else{
console.log('test2');
component.set("v.checkTab",true);
} });
$A.enqueueAction(action);
console.log('yep1'); },
The console.log inside callBack is not being executed. Only the console.log(yep1) and (yep2).
Here is the Apex:
@AuraEnabled public static Boolean hasCustomerInteractionOpen(String aCaseId){
try{
Case lCase = [SELECT AttendanceProtocol__c, Id, Status, AttendanceProtocol__r.LastModifiedDate, AttendanceProtocol__r.vlocity_cmt__Status__c, OwnerId FROM Case WHERE Id =: aCaseId LIMIT 1];
if((String.isNotBlank(lCase.AttendanceProtocol__c)) && (lCase.AttendanceProtocol__r.vlocity_cmt__Status__c != 'Closed') && (lCase.OwnerId == (UserInfo.getUserId()))){
List<Case> lCaseCustomer = [SELECT Id,AttendanceProtocol__c, Status, ClosedDate FROM Case WHERE AttendanceProtocol__c =: lCase.AttendanceProtocol__c ORDER BY ClosedDate DESC];
if((lCaseCustomer[0].Id == lCase.Id) && ((lCase.AttendanceProtocol__r.LastModifiedDate) < (lCaseCustomer[0].ClosedDate))){
System.debug('true'); return true; }
} System.debug('false');
return false;
}catch(Exception e){ System.debug('The following exception has occurred: ' + e.getMessage()); return false; } }
The system.debug is returning in the debugging. So, the apex is being called, returning a value.
But the action.setCallBack is not accessing this value. I'm on it has two days, someone can help me? Really appreciate it.
Please use below code in your component it will be work:-
if you need any assistanse, Please let me know!!
Kindly mark my solution as the best answer if it helps you.
Thanks
Mukesh