3

The documentation states the following

https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_annotation_InvocableVariable.htm

The data type of the invocable variable must be an Apex class or a list of Apex classes.

This is obviously 100% wrong because the same page lists a bunch of examples of primitive data types using the @InvocableVariable annotation

global ID leadId;

@InvocableVariable(required=true)
global String convertedStatus;

@InvocableVariable
global ID accountId;

@InvocableVariable
global ID contactId;

@InvocableVariable
global Boolean overWriteLeadSource;

@InvocableVariable
global Boolean createOpportunity;

@InvocableVariable
global String opportunityName;

@InvocableVariable
global ID ownerId;

@InvocableVariable
global Boolean sendEmailToOwner;

Also, in my org, I can use the annotation on a list of SObjects, even though this is not documented

 @AuraEnabled @InvocableVariable
public List<OpportunityLineItem> lineItems;

That said, when I try to reference said variable in a Flow, I get an internal server error.

Does anyone know why the documentation is so outdated/wrong and which are the truly supported data types for this annotation?

1 Answer 1

2

Take a look at the V45.0 version of the doc

This looks more like what one would expect from the examples:

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.

Apex types were added in V46.0. There are a slew of examples of ApexTypes as return variables in this GitHub repo

See also apex-types for Flow doc example. be sure your Apex Type is an outer class

5
  • So it seems that the newer version has the wrong data types Commented Nov 6, 2019 at 12:54
  • @CommonCoreTawan - you should file doc feedback
    – cropredy
    Commented Nov 6, 2019 at 19:36
  • do you know how? I don't have premier support. Basic support is allergic to the word "apex" Commented Nov 7, 2019 at 12:27
  • There's a feedback button on the doc page
    – cropredy
    Commented Nov 7, 2019 at 15:03
  • Thanks! will do Commented Nov 7, 2019 at 15:24

You must log in to answer this question.

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