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?

0

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

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

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.