web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested Answer

How to correctly pack and unpack objects

(0) ShareShare
ReportReport
Posted on by 174

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();
    }

I have the same question (0)
  • Martin Dráb Profile Picture
    238,740 Most Valuable Professional on at

    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.

  • RadekM Profile Picture
    174 on at

    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.

  • Martin Dráb Profile Picture
    238,740 Most Valuable Professional on at

    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.

  • RadekM Profile Picture
    174 on at

    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.

  • Suggested answer
    Martin Dráb Profile Picture
    238,740 Most Valuable Professional on at

    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.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 577 Super User 2026 Season 1

#2
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 309

#3
Diego Mancassola Profile Picture

Diego Mancassola 259

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans