Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

How can I get a class buffer set in previous caller to a batch job class?

(0) ShareShare
ReportReport
Posted on by 2,016

Hi Techies,

I have written a multi-threading batch job class(extends RunbaseBatch) in which I need to access one class buffer that is traversing from previous callers. I brought that buffer till this multi-threaded class by setting and getting with parm methods. whereas I can access this buffer if I don't run this class in batch, but when I enable the 'Run in batch' checkbox and executes, it loses the buffer and sets to null.

I can't add it in macro list as it is a heavy object and cannot be added in container.

I have an alternate solution, where I can reconstruct this when I run in batch and that works too, but to see the output after successful execution of batch job I need to open a complete new form and then navigate till this form to check the output. Whereas the expectation is whenever execution of batch job completes successfully I should close the form and it should show result in previous form, so the refresh is not happening correctly on this previous form even after writing refresh code because we construct new buffer in batch class.(which losses few other references).

Can anyone help me out here on how can I access the same class buffer instead of reconstructing new? or suggest other solution where I can see output once I close the current form instead of opening in new tab.

Any response is appreciated.

Thanks!

  • Sangram Shinde Profile Picture
    Sangram Shinde 2,016 on at
    RE: How can I get a class buffer set in previous caller to a batch job class?

    Agreed Nikolaos, thanks for the inputs!

  • Verified answer
    nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: How can I get a class buffer set in previous caller to a batch job class?

    I'm not sure if I understand correctly. But perhaps it helps if we think how the batch class works.

    When you set it to run in batch, it stores all "input parameters" (defined in [tag:CurrentList]), packs them in a container and saves this container in the database.

    When the batch actually runs, it reads this container from the database, unpacks it, retrieves the variables and instantiates the class. Then the class is executed.

    This instance of your class can't see any "caller" classes (there aren't any - this class was just instantiated by the batch framework!). And it can't see (or refresh or close!) any forms that some user session might or might not have open.

    It's just not possible that the caller class instance could be somehow stored in the batch. It exists only in your user session. When you don't run your class in batch, different class instances in your session can see each other (presuming you pass pointer of that class to another class). But it can't work like that in batch.

  • Sergei Minozhenko Profile Picture
    Sergei Minozhenko 23,091 on at
    RE: How can I get a class buffer set in previous caller to a batch job class?

    Hi,

    Is it about AX 2012 or D365?

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,321 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans