6

I'm building an Apex action for Process Builder and would ideally like to pass in a list of strings as an @InvocableVariable. Per the SFDC documentation, "The data type of the invocable variable must be[... a] primitive data type or a list of a primitive data type."

I can create an @InvocableVariable as follows and it compiles fine, but I can't for the life of me figure out how to populate the variable from within Process Builder.

    @InvocableVariable
        (label='Fields to Query'
         required=false)
    public list<string> fieldsToQuery;

The desired use case is to allow the user to define zero, one, or many field names which will then be queried, json-encoded, and used in the Apex method.

My last resort is to just accept a comma-delimited string, but I don't think that should be necessary :(. Any ideas would be greatly appreciated!

  • Have you tried to define public class SomeClass { @InvocableMethod(label='Some method' description='Some method') public static void someMethod(List<String> fieldsToQuery) { } } – Patlatus Feb 15 '17 at 13:22
0

Have you tried passing in comma delimited String

String fieldsToQuery = 'field1, field2, field3, field4';

Then splitting the String into an Array ?

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.