1

I have a flow that returns the List to the Apex class. The apex class is the REST API that try to convert the output as JSON it returns null, so I have tried to iterate the list to assign the another wrapper to convert that as string.

 List<CustomWrapper> lstWrapper = ( List<CustomWrapper> )contFlow.varOutput;

It throws following error:

System.QueryException: Dynamic query yields incompatible SObject type java:interaction.engine.interview.FlowApexObject for loop variable of type CustomWrapper

It works fine when I pass the output as List of sObjects.

2 Answers 2

0

There is a workaround that you can apply easily.

Since we can get String value as output from flows, you can serialize your Apex-defined variable and set it as output. Later grab that output (String) and deserialize to your original object which Apex-defined type class.

Just create and add a new Apex class (input Apex-defined type and output List) to your flow for serialization before setting output.

0

The only potential answer I can provide is from the documentation here : https://help.salesforce.com/articleView?id=flow_considerations_apex_data_type.htm&type=0

It specifies that "An Apex-defined variable value can't be set or stored outside the flow." This suggests that you can't store the flow variable to an apex representation. Even if they are supposed to be of the same class.

1
  • i did not get any answer to this problem. I have tried use multiple output variables and Sobject results, but that could complicate my solution. so I ended up using Apex class instead of flow. May be salesforce support can tell what exactly going on with this. possibly this is platform limitation as you mentioned "An Apex-defined variable value can't be set or stored outside the flow. The value can't be passed to a Subflow element."
    – goodForce
    Commented Mar 15, 2021 at 17:50

You must log in to answer this question.

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