I am trying to call an apex method through a controller. I have read somewhere the apex methods without any return should be prefixed with get. I am not sure what I am doing wrong here. It says cant find the method.
here is the apex:
for (Opportunity opp : [Select Id, Name, StageName from Opportunity]) {
opp.StageName = 'Won';
update opp;
}
Here is the call from the controller:
changeStageBackWon : function(component, event, helper) {
var updateOpportunityStageBackWon = component.get("c.getMoveOppBackWon");
//updateOpportunityStageBackWon.setParams({ opps : component.get("v.opportunityData") });
updateOpportunityStageBackWon.setCallback(this, function(response) {
var state = response.getState();
if (state === "SUCCESS") {
var result = response.getReturnValue();
console.log(result);
}
});
$A.enqueueAction(updateOpportunityStageBackWon);
}
Best Answer
In all Apex methods, that are not returning something back, we will need to declare them as
void
. So you need to do something like this:or
Check this link to learn more about Apex methods.