0

Edit: I've tried this by creating virtual/abstract class and setting it as the parameter for the invocable and then made an extension and passed it from the flow. Flow doesn't seem to allow this, it only accepts the base virtual/abstract classes and not the extensions. Also generic Object are not allowed as parameters for invocable methods and as invocable variables.

I've seen a similar implementation for Generic SObjects, but wondering if there's a way to to this for Wrappers. https://unofficialsf.com/pass-objects-to-flow-via-rest-with-the-serializedeserialize-collection-actions/

1 Answer 1

0

You can deserialize/serialize any class you want. Just create a Wrapper class and then:

String wrapperString = System.JSON.serialize(wrapperItem);
Wrapper myWrapper = (Wrapper) System.JSON.deserialize(wrapperString , Wrapper.class);

https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_System_Json.htm#apex_System_Json_deserialize

2
  • N.B. some types are unserializable (SobjectField, SObjectType, ...)
    – cropredy
    Nov 15, 2021 at 18:01
  • Thanks for your answer. I was actually thinking whether it's possible to make it reusable. Right now, from the flow can only pass the exact same wrapper I've set as the parameter on the invocable method. I've tried creating an abstract/virtual class then set it as the parameter and created extensions of that class, but still on flows it only accepts the base abstract/virtual class.
    – jema
    Nov 16, 2021 at 8:44

You must log in to answer this question.

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