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

Notifications

Announcements

No record found.

Community site session details

Community site session details

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

which method and class is best approach to add code during PO invoice in AX 2012?

(0) ShareShare
ReportReport
Posted on by 30

hi all,

i have to add some logic in Purchase order  during Invoice as per business requirement..

As i know purchInvoiceJournalPost is called during PO invoice. i have debugged the PO invoice but not understand where we can add the code during invoice?

Kindly let me know which method and class is best approach to add code during PO invoice ?

Please give me more shed on this 

I have the same question (0)
  • @rp@n Profile Picture
    30 on at

    Hi all

    Once available,  please reply me on this

  • Suggested answer
    ergun sahin Profile Picture
    8,826 Moderator on at

    The code goes through many classes and methods. The place where you write the code depends on the job you want to do.

    For example, if you're going to send a custom field from purchline, look at the VendInvoiceInfoLine.initFromPurchLine () / VendDocumentLineType_Invoice method.

    sites.google.com/.../howtopasscustomfieldfrompolinetoinvoiceline

    community.dynamics.com/.../copy-custom-field-from-po-line-to-invoice-line

    If you're going to add a new process, you can focus on the PurchInvoiceJournalCreate or PurchInvoiceJournalPost (may be postVendCust)classes.

    docs.microsoft.com/.../using-the-refactored-formletter-framework-white-paper

    Right now I dont have ax so I didnt check method names. Tomorrow I will write agin after check

  • @rp@n Profile Picture
    30 on at

    Thanks Ergun,

    The requirement is

    I have added a check box "Misc PO" and Charges code in PurchCreateOrder form.

    If user mark Yes in Misc PO then the PO should consider as Misc PO not normal PO.

    For example -  In the charges code master they setup GL account suppose 11405.

    If the PO is MISC PO then the PO invoice should hit the GL account 11405 based on charges code setup.

    And for the NORMAL PO, It should work like STANDARD PROCESS.

    Basically I need to put condition during PO INVOICE , it SHOULD CHECK

    if the PO is MISC. PO then it should hit GL account which is mapped with CHARGES CODE and if the PO is NORMAL PO then it should work like STND. PROCESS.

    Kindly let me know the correct place to write code. I mean the which class and method ?

    Please give me more shed on this

  • @rp@n Profile Picture
    30 on at

    Hi Ergun,

    Is it PurchInvoiceJournalPost class - Post Line method ?

    4075.J1.jpg

    but I not found any code in PostLine method. and also this.journlizeDocument() .

    Where the method get implemented?

    Please give me more shed on this

  • @rp@n Profile Picture
    30 on at

    Hi Ergun,

    I put the debugger in init method of "PostInvoiceJournalPost" class and do the post.

    then it's goes to

    FormLetterJournalPost > Post method.

    In the post method , it's called many methods form PostInvoiceJournalPost class like

    PostLine

    PostMarkupLine

    UpdateJournalLine

    UpdateSourceLine etc...

    Kindly guide me which method , we can put condition based on my above scenario?

    Please give me more shed on this

  • ergun sahin Profile Picture
    8,826 Moderator on at

    There were many methods I would say if it was another field, but if you say I want to change the GL account, I think you should do it first. Why don't you change it on the PO.

  • @rp@n Profile Picture
    30 on at

    Hi,

    Have you understand my requirements?

  • OsmanIstanbul Profile Picture
    2,818 on at

    Hi @rp@n

    why do you add the charge code PurchCreateOrder form? how will you change posting account? there are lots of account and posting types on purchase invoice vouchers. can you clarify your question please? some screenshots will be great.

    Best Regards

  • @rp@n Profile Picture
    30 on at

    Hi Osman,

    Just forgot about all the customization which I have required.

    Only tell me if I POST ANY PURCHASE ORDER THEN WHICH CLASS AND METHOD MAINLY CALLED DURING INVOICE.

    I AM LOOKING FOR EXACT METHOD.

    Please give me more shed on this

  • OsmanIstanbul Profile Picture
    2,818 on at

    Hi @rp@n,

    As Ergun mentioned there are lots of methods and Ergün listed some of them. But to verify which one is the right method, we must know more details. So I am not able to help you more.

    Best Regards.

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 422 Most Valuable Professional

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 239 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans