function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
SrtSrt 

My controller action not getting recognized in lightning

Component:

 

<aura:component controller="SBQ_test"

  implements="force:lightningQuickActionWithoutHeader,force:hasRecordId">
 

  <aura:handler name="init" value="{!this}" action="{!c.doInit}" />  

</aura:component>
 

Controller:


({

  doInit : function(component, event, helper) {

 

 var action = component.get("c.doWork");

 action.setParams({

  "recId": component.get("v.recordId")

          });

 // Configure response handler

 action.setCallback(this, function(response) {

     var state = response.getState();

     if(state === "SUCCESS") {

     } else {

         console.log('Problem getting account, response state: ' + state);

     }

 });

 $A.enqueueAction(action);

 $A.get("e.force:closeQuickAction").fire();

 $A.get("e.force:refreshView").fire();

 },





Relevant Class:
 

public class SBQ_test {

  public void doWork(ID recId) {

      //perform SOME action here ON object

     try{

          update oject;
      }

  }
}

I am getting error Unknown Controller Action doWork?? Why? Pls help
Raj VakatiRaj Vakati
Try to modify the Apex controller code as shown below ... Rest of code looks good. 
You missed @AuraEnabled annotation.
 
public class SBQ_test {
@AuraEnabled 
  public static void doWork(ID recId) {
      //perform SOME action here ON object
     try{
          update oject;
      }
  }
}