0

I'm trying to write a simple text class for another simple class that has an @InvocableMethod method, but receive the save error in the question's title. I can't figure out its cause or how to overcome it.

Class with @InvocableMethod Method:

global with sharing class InputOutput_Placeholder_Plugin {

    @InvocableMethod
    public static List<List<String>> placeholderText(List<String> input) {

        String s  = input.get(0);
        List<String> allString = new List<String>();
        List<List<String>> allStrings = new List<List<String>>();

        allString.add(s);   
        allStrings.add(allString);

        return allStrings;
    }
}

Test Class:

@isTest
private class InputOutput_Placeholder_Plugin_Test {

    static testmethod void InputOutput_Placeholder_Plugin_Tests() {

        InputOutput_Placeholder_Plugin plugin = new InputOutput_Placeholder_Plugin();
        String s = 'Searching';
        List<String> stringList = new List<String>();
        stringList.add(s);

        plugin.placeholderText(stringList);  
    }    
}

The error occurs at plugin.placeholderText(stringList);

Thanks in advance.

1 Answer 1

3

Change:

plugin.placeholderText(stringList);  

With:

InputOutput_Placeholder_Plugin.placeholderText(stringList);  

Static method or variables can be accessed by class name, only non-static ones require class instance for invocation.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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