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

Community site session details

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

How to get different table buffer's in XppPrePostArgs in X++ , D365

(0) ShareShare
ReportReport
Posted on by 339

Hi Experts,

I have taken post-event handler for initProdTableJour method in this class ProdUpdHistoricalCost_Process.

In that method 3 tables are present, 1 is ProdTable, 2 is ProdParmHistoricalCost and 3 is ProdTableJour.

This post-event handler has XppPrePostArgs as arguments.

while debugging i am getting recid's in the debugger

0878.batch-order.PNG

if we have taken post event handler for one specific table level method, we can write

tablename  buffer = args.getThis();

But,How to the specific table buffers?

can any one help me to achieve this.

Thanks,

with regards,

srihari. 

I have the same question (0)
  • Suggested answer
    Mea_ Profile Picture
    60,284 on at
    RE: How to get different table buffer's in XppPrePostArgs in X++ , D365

    Hi Srihari.molaka,

    You can get parameters by name, lets say parm name is "_prodTable" then you can get it like this

    ProdTable prodTable = _args.getArg(identifierStr(_prodTable)) as ProdTable;

  • Verified answer
    Martin Dráb Profile Picture
    236,297 Most Valuable Professional on at
    RE: How to get different table buffer's in XppPrePostArgs in X++ , D365

    prodTableJour is an instance variable of the class. Use CoC and simply refer to prodTableJour by name:

    public void initProdTableJour(Voucher _voucher)
    {
    	next initProdTableJour(_voucher);
    	
    	info(prodTableJour.InventTransId);
    }

  • Srihari.molaka Profile Picture
    339 on at
    RE: How to get different table buffer's in XppPrePostArgs in X++ , D365

    hi ievgen,

    Thanks for your reply,

    I have tried it but it is not working.

    with regards,

    srihari.

  • Mea_ Profile Picture
    60,284 on at
    RE: How to get different table buffer's in XppPrePostArgs in X++ , D365

    Can you share your code? It's hard to say what does not work without seeing it.

    Also please consider approach proposed by Martin, CoC is a better and easier way to achieve this.

  • Srihari.molaka Profile Picture
    339 on at
    RE: How to get different table buffer's in XppPrePostArgs in X++ , D365

    Hi Martin Drab,

    Thanks for replying,

    just now I tried and achieved it.

    Thanks,

    with regards,

    srihari.

  • Srihari.molaka Profile Picture
    339 on at
    RE: How to get different table buffer's in XppPrePostArgs in X++ , D365

    Hi Martin Drab,

    can I know when to use COC and event handler?

    In this case, why cannot I achieve with post event handler?

    Thanks,

    srihari.

  • Martin Dráb Profile Picture
    236,297 Most Valuable Professional on at
    RE: How to get different table buffer's in XppPrePostArgs in X++ , D365

    Pre-/post-method events and XppPrePostArgs used to be used when CoC didn't exist. I don't see any reason anymore for using it - CoC is more powerful, safer and easier to use.

    The variable is protected and you can access protected variables from class extensions (CoC), but not from other classes (such as your event handler class). You can get the instance of ProdUpdHistoricalCost_Process by XppPrePostArgs.getThis(), but you cannot simply access the protected variable. You would need a public method returning the variable and I don't know if the class has such a 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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

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

#1
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 2,167

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 867 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 617 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans