How can I pass _args by pack / unpack methods? Like this example the caller() object reference not set... And true when I look at passed _args and what it unpacked the content is almost is mostly null or '0'. I need to get access to formDataSource in the second static method.
public static void main(Args _args) { MyClass::passArgs(_args.pack()); } public static void testingPack(container _args) { Args myArgs = new Args(); myArgs.unpack(_args); FormRun formRun = myArgs.caller(); }
Your code snippet shows some unrelated methods. main() calls passArgs(), which isn't mention anywhere else. Then there is testingPack(), but it doesn't seem to have anything to do with main().
In either case, a container can't hold references to objects, such as a FormRun instance, therefore the whole idea is invalid.
My bad didn't noticed I made a name mistake. It should be passArgs() instead of testingPack(). Anyway I wondered because I was passing a container _args.pack() and passArgs(container) values looked valid, the references broke when I unpacked the container.
Anyway is there a way to share or pass _args between two or more static methods? Tried to declare static args outside of method and use copyArgs() in main but looks like the second method see it just as new args.
Sure, you can pass object references between static method. But that has nothing to do with packing. Either you actually don't need any packing, or you likely wanted to ask a different question. I can't know, because you told us nothing about actual scenario.
This screnario is actually a continuation of my previous thread. I try runAs() method but it only accept a container as parameters. I does accept the pack() so I tried to go this way. I need to be able to use the _args from the method calling runAs() in called method and both are static.
Packing an instance of Args classs to a container and unpack it to another Args object is possible, but it won't help you with your requirement "I need to get access to formDataSource". You can't put a memory address of an object to a container. You'd need to pack the form data source object, which can't meaningfully be done.
You need to think about what information you actually need and find a way how to put it into a container. For example, if you want to get records selected in a form, you can use MultiSelectionHelper to iterate the records, store their IDs in a Set, pack the Set to a container and pass this container to your method.
Under review
Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.
As AI tools become more common, we’re introducing a Responsible AI Use…
We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
CA Neeraj Kumar 2,029
André Arnaud de Cal... 871 Super User 2025 Season 2
Sohaib Cheema 582 User Group Leader