+ Start a Discussion
Gopinath418Gopinath418 

Can we call a @InvocableMethod method from a @auraenabled method?

I have a lightning component and it has an apex controller. I would like to call a @InvocableMethod of an another class from the ligtning component conroller @auraenble method. Is this possible? If so could you please provide an example

Thanks 
Gopinath
Best Answer chosen by Gopinath418
sfdcMonkey.comsfdcMonkey.com
Hi gopinath, Yes you can call InvocableMethod from auraEnabled method
i.e
 
public class InvocClassTest {
  @InvocableMethod(label='Test' description='test desc')
  public static void getAccountNames() {
    system.debug('Yes am able to call..');
  }
}

lightning component controller class method :
 
public with sharing class LightningController {
   @AuraEnabled
    public static void getopportynity(){
     // call InvocableMethod 
      InvocClassTest.getAccountNames();

        System.debug('limits'+limits);
    }
}

In debug log you can check the system.debug result for both method

Thanks
let us know if it helps you and close your query if you got your answer
 

All Answers

sfdcMonkey.comsfdcMonkey.com
Hi gopinath, Yes you can call InvocableMethod from auraEnabled method
i.e
 
public class InvocClassTest {
  @InvocableMethod(label='Test' description='test desc')
  public static void getAccountNames() {
    system.debug('Yes am able to call..');
  }
}

lightning component controller class method :
 
public with sharing class LightningController {
   @AuraEnabled
    public static void getopportynity(){
     // call InvocableMethod 
      InvocClassTest.getAccountNames();

        System.debug('limits'+limits);
    }
}

In debug log you can check the system.debug result for both method

Thanks
let us know if it helps you and close your query if you got your answer
 
This was selected as the best answer
Gopinath418Gopinath418
thanks Piyush