4

BACKGROUND

I have a class with an InvocableMethod which takes a set of InvocableVariable's

Such that I can call the Apex class from Process Builder.

QUESTION

I would like one of the fields to appear as a dropdown list of options when configuring within Process Builder.

ATTEMPTS

I have tried setting the InvocableVariable type as a custom class:

global class TestType { 

    public final String VALUE_ONE = 'one';
    public final String VALUE_TWO = 'two';

}

And I have tried setting the InvocableVariable type as an Enum:

public enum Season 
{
    WINTER, 
    SPRING, 
    SUMMER, 
    FALL
}

Both give me an error of:

InvocableVariable fields do not support type of XXX

How do I define the InvocableVariable such that I can pick from a set of options?

3 Answers 3

3

It's not possible.

The invocable variable can’t be one of the following:

  • A type such as an interface, class, or enum.

  • A non-member variable such as a static or local variable.

  • A property. A final variable. Protected or private.

The data type of the invocable variable must be one of the following:

  • A primitive data type or a list of a primitive data type – the generic Object type is not supported.

  • An sObject type or a list of an sObject type – the generic sObject type is not supported.

Reference:

1

So, one option would be to define (or reuse an existing) Sobject Foo__c with a custom picklist field that has the value set you care about.

Seasons__c type picklist with values SPRING, ...

Then have the invocable method support a list of Foo__c as the argument. This will provide the dropdown values you need.

1
  • @Robs -- Have the PB invoke a Visual Flow that in turn calls the invocableApex using custom Sobject Foo__c. VisualFlow supports choosing from existing picklist values in the Assignment operation
    – cropredy
    Jul 9, 2018 at 19:23
1

@Robs i am not sure if you manage to find best possible solution.

I use to do like this, so at least user know possible values for the parameter.

    @InvocableVariable(label='Season' description='Type one of these WINTER, SPRING, SUMMER, FALL' required=true)
    public String season;

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .