You need to sign in to do that
Don't have an account?
John Manager Training Dep
Class called from aura component not getting executed in lightning page?
Hi Team,
In my org, I see there is a code to update the read unread checkbox(r_u_cbox) field to true when the current owner of a case opens the record on the salesforce page and refreshes it.
I was able to test the UpdateCaseCheckboxonRef class to cover 100% of the code but when I add the aura component to the lightning page layout, the class functionality does not seem to execute. Could anyone guide please?
Class is mentioned below,
The aura components are mentioned below,
.cmp aura
helper.js aura
In my org, I see there is a code to update the read unread checkbox(r_u_cbox) field to true when the current owner of a case opens the record on the salesforce page and refreshes it.
I was able to test the UpdateCaseCheckboxonRef class to cover 100% of the code but when I add the aura component to the lightning page layout, the class functionality does not seem to execute. Could anyone guide please?
Class is mentioned below,
public class UpdateCaseCheckboxonRef { @AuraEnabled public static boolean execFunc(string idOfCase) { string name; case currRec = [Select id, r_u_cbox, status, OwnerId, Owner.Username FROM case where id =:idOfCase]; if(currRec.OwnerId == UserInfo.getUserId() && !currRec.r_u_cbox) { currRec.r_u_cbox = true; update currRec; return true; } else{return false;} } }
The aura components are mentioned below,
.cmp aura
<aura:component controller="UpdateCaseCheckboxonRef" implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction,lightning:actionOverride" access="global" > <lightning:workspaceAPI aura:id="workspace"/> <aura:handler name="init" value="{!this}" action="{!c.doInit}" /> </aura:component>.js controller aura
({ doInit : function(component, event, helper) { var contactId = component.get("v.recordId"); var action = component.get("c.execFunc"); action.setParams({ "Id": contactId}); action.setCallback(this, function(response) { var state = response.getState(); var res = response.getReturnValue(); console.log('res valuse'+JSON.stringify(res)); if(res == "true"){ var workspaceAPI = component.find("workspace"); workspaceAPI.getFocusedTabInfo().then(function(response) { var focusedTabId = response.tabId; workspaceAPI.refreshTab({ tabId: focusedTabId, includeAllSubtabs: true }); }) .catch(function(error) { console.log(error); }); } }); } })
helper.js aura
({ helperMethod : function() { } })
Greetings to you!
+1 Maharajan
You need to use $A.enqueueAction(action); It adds the server-side controller action to the queue of actions to be executed. Please try below code:
I hope it helps you.
Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.
Thanks and Regards,
Khan Anas
All Answers
Param Name should be same as you defined in execFunc method:
({
doInit : function(component, event, helper) {
var caseId = component.get("v.recordId");
var action = component.get("c.execFunc");
action.setParams({
"idOfCase" : caseId});
action.setCallback(this, function(response) {
var state = response.getState();
var res = response.getReturnValue();
console.log('res valuse'+JSON.stringify(res));
if(res == "true"){
var workspaceAPI = component.find("workspace");
workspaceAPI.getFocusedTabInfo().then(function(response) {
var focusedTabId = response.tabId;
workspaceAPI.refreshTab({
tabId: focusedTabId,
includeAllSubtabs: true
});
})
.catch(function(error) {
console.log(error);
});
}
});
}
})
Thanks,
Maharajan.C
Additionally, also tried with below in the .cmp aura but no success.
Any constructive suggestion much appreciated!
Greetings to you!
+1 Maharajan
You need to use $A.enqueueAction(action); It adds the server-side controller action to the queue of actions to be executed. Please try below code:
I hope it helps you.
Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.
Thanks and Regards,
Khan Anas