+ Start a Discussion
Valentina ErmilovaValentina Ermilova 

Can't find apex class with invocable method in Process Builder on production org

Can't find apex class with invocable method in Process Builder on production org. On develop org it works fine.
User-added image
I tryed recompile all classes, it did not help. Class successfuly pass test. Please, what can be wrong?
 
global class SearchObjectWhenCreate {

global class Request {
    @InvocableVariable
    public String objectId;
    @InvocableVariable
    public String searchType;
}

@InvocableMethod
public static void searchObject(List<Request> requests) {

    SearchButtonsController searchButtonsCtrl = new SearchButtonsController();
    List<verf__VF_Search__c> listOfSearches = new List<verf__VF_Search__c>();

    if (Schema.sObjectType.VF_Search__c.fields.Id.isAccessible()){
        listOfSearches = [SELECT Id
                        FROM verf__VF_Search__c
                        WHERE Name =: requests[0].searchType
                        LIMIT 1];
    }
    if(!listOfSearches.isEmpty()){
        searchButtonsCtrl.vf_searchId = listOfSearches[0].Id;
        searchButtonsCtrl.strObjectId = requests[0].objectId;
        searchButtonsCtrl.getObjectInfo();
        searchButtonsCtrl.isCalledFromProcessBuilder = true;
        searchButtonsCtrl.searchRequest();
        request(searchButtonsCtrl.xmlStringxmlRes, searchButtonsCtrl.vf_searchName);
    }
}

@future(callout=true)
public static void request(String xmlStringxmlRes, String searchName) {
    Http httpProtocol = new Http();
    HttpRequest request = new HttpRequest();
    HttpResponse response = new HttpResponse();
    String body = 'request=' + xmlStringxmlRes;

    String endpoint = 'https://viqzrh5hp3.execute-api.us-east-1.amazonaws.com/verified_first';
    request.setEndPoint(endpoint);
    request.setBody(body);
    request.setMethod('POST');

    try {
         if(!Test.IsRunningTest()){
            response = httpProtocol.send(request);
            parseXMLResponce(response.getBody(), searchName);
        }
    } catch(System.CalloutException e) {
    }
}

 
Best Answer chosen by Valentina Ermilova
Valentina ErmilovaValentina Ermilova
From documentation (https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_annotation_InvocableMethod.htm):

An invocable method can be public in a managed package, but it won’t appear as an action in the Cloud Flow Designer’s list of available actions while building or editing a flow. These invocable actions can still be referred to by flows within the same managed package. Global invocable methods in a managed package can be used in flows outside the managed package, anywhere in the organization, and appear in the Cloud Flow Designer’s list of available actions to add to a flow.

So with global invocable methods and global invocable variables all works on production. Solution was found. Thanks!

 

All Answers

Sudipta DebSudipta Deb
Hi Valentina, 

Please follow the below steps.
  • Locate the Apex Class 
  • Go to Develop | Apex Classes | <Your Apex Class>
  • See if the Status says it is active. If not, next step
  • Use Developer Console or Setup | Develop | Apex Test Execution and run the tests for that class.
This will make the class active and available for use in Process Builder.
Please let me know if this helps your problem. Thanks.

Regards,
Sudipta Deb.
 
Valentina ErmilovaValentina Ermilova
Hi Sudipta,
Thanks for idea. Class already is active, but still isn't availiable if Process Builder.
Valentina ErmilovaValentina Ermilova
From documentation (https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_annotation_InvocableMethod.htm):

An invocable method can be public in a managed package, but it won’t appear as an action in the Cloud Flow Designer’s list of available actions while building or editing a flow. These invocable actions can still be referred to by flows within the same managed package. Global invocable methods in a managed package can be used in flows outside the managed package, anywhere in the organization, and appear in the Cloud Flow Designer’s list of available actions to add to a flow.

So with global invocable methods and global invocable variables all works on production. Solution was found. Thanks!

 
This was selected as the best answer
Murthy AlluriMurthy Alluri
I have simliar issue class not found in flow designer, what could be the issue?
Murthy AlluriMurthy Alluri
working now, thank you
Yahor VolkauYahor Volkau
I had the similar problem, but fixed it for public class:
1) close Process Builder
2) go to Setup / Develop / Apex Classes and click "Compile all classes"
3) go to your process and select your class
Bruce StewartBruce Stewart
Anyone else experience this is DEV org.
I have no tests for 1 class that DOES show up ok in PB and Flow (created last night).
Basically copied that one, changed some things in class- 2nd one does not show up.

Tried @Yahor Volkau's compile all classes steup.  Finished.  No change.
Gopal Singh 17Gopal Singh 17
Very recently i experianced the same issue and found that if You use invocable annotation in your apex class like
@InvocableMethod(label='Convert Leads')
It will not appear in the process builder .
But if you use simply 
@InvocableMethod
It will work.

Thanks,
Gopal Singh
Fernando GlinganiFernando Glingani
Hello everyone, I have an issue almost like that in my sandbox org. I have created an apex class and it showed up on flow builder. I configure the input/output variables into my flow. So, I change something on my apex class and now it does not show up anymore. I had 100% coverage code, compile all class and nothing. Anyone has experienced anything like that before ?

PS. I have tried what @Valentina and @Gopal Singh sugestions.

Regards

Fernando
Izzy DeveloperIzzy Developer
Go to your apex class, copy all of the code, create a new apex class, paste your code there, change the class name slightly, make sure your method is invocable, save the class. Now search for your class from within process builder.
Pratik Gangawane 14Pratik Gangawane 14
Hello everyone,
I have faced same issue while creating new Update Opportunity process to call an Apex action (named Post Opportunity To PMS) to pass Integration superbadge's 3rd challenge.
just need to update/add @InvocableMethod annotation for method postOpportunityToPMS() of class ProjectCalloutService.
Thank you.