I am trying to use following apex class with invocable method but its not showing in process builder.

global with sharing class SlackOpportunityPublisher {

    private static final String slackURL = 'https://testsalesforceapps.slack.com/';

    global class Oppty {
        @InvocableVariable(label='Opportunity Name')
        global String opptyName;
        global String stage;

    @InvocableMethod(label='Post to Slack')
    global static void postToSlack(List<Oppty> oppties) {
        Oppty o = oppties[0]; // If bulk, only post first to avoid overloading Slack channel
        Map<String,Object> msg = new Map<String,Object>();
        msg.put('text', 'The following opportunity has changed:\n' + o.opptyName + '\nNew Stage: *' + o.stage + '*');
        msg.put('mrkdwn', true);
        String body = JSON.serialize(msg);    
        System.enqueueJob(new QueueableSlackCall(slackURL, 'POST', body));

    global class QueueableSlackCall implements System.Queueable, Database.AllowsCallouts {

        private final String url;
        private final String method;
        private final String body;

        global QueueableSlackCall(String url, String method, String body) {
            this.url = url;
            this.method = method;
            this.body = body;

        global void execute(System.QueueableContext ctx) {
            HttpRequest req = new HttpRequest();
            Http http = new Http();
            HttpResponse res = http.send(req);


  • I suppose your process builder on Opportunity. – Raul Sep 27 '17 at 14:14
  • yes you are right! – sekhar Sep 27 '17 at 14:17
  • Changing signature of class and/or method to public make any difference? – Raul Sep 27 '17 at 14:21
  • I tried before with public also but that time also faced same problem – sekhar Sep 27 '17 at 14:25
  • 1
    I copy pasted your class in my dev org and it works!! Issue is similar to this question. Try creating a new class and see if it appears? – Raul Sep 27 '17 at 14:34

This problem often resolves itself by going to Setup | Develop | Apex Classes | select the test class and then run tests. SFDC needs to be sure class has been tested to appear in dropdown.

Solution also applies to Schedulable classes, Inbound Email Handler classes

| improve this answer | |
  • Great to know the solution. Thanks for sharing. But this doesn’t make sense, shouldn’t it register the class while creation? Also would compile all classes also work instead of running test class? – Raul Sep 27 '17 at 18:13
  • 1
    @RahulSharma - all I can say is I learned this trick from elsewhere and it works – cropredy Sep 27 '17 at 23:44
  • 2
    @Raul I can confirm the compile all classes solution works, independent of test coverage. In a dev org, I have methods that show up after 'compile all' that have no coverage whatsoever. – Vince Feb 7 '19 at 19:20

Go to Apex class list > compile all the classes

That should solve the issue.

| improve this answer | |
  • This worked once for me and then it disappeared again and only showed up after I added test coverage :shrug: – NSjonas Jun 4 at 19:45

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 and has a label, save the class. Now search for your method label from within process builder.

| improve this answer | |

Another workaround is to change the method parameter.

Switching to List<Id> instead of List<Sobject> worked for me.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.