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, ...
Answered

Public Void postLoad()

(0) ShareShare
ReportReport
Posted on by 414

Hi All,

Please can you help me changing below code so It looks at two columns 'InventTransId' and 'InvoiceId' to find appropriate transaction.

As per below Snip InvenTransId is used to locate specific transaction.

1033.Code.JPG

I need help adding InvoiceId as second parameter to filter transaction.

Appreciate your help on this.

I have the same question (0)
  • WillWU Profile Picture
    22,361 on at

    Hi YOG,

    Do you mean that you want to find transaction by InvoiceId ?

    Try this code:

    CustTrans custTrans=CustTrans ::findFromInvoice(invoiceId);

    Hope this helps.

  • YOG Profile Picture
    414 on at

    Hi Will,

    I want to find transaction by both InventTransId and InvoiceId.

    Below code did not work!

    0726.err.JPG

  • Suggested answer
    nmaenpaa Profile Picture
    101,160 Moderator on at

    Seems you have some challenges with the x++ syntax.

    Please replace the "&&" with ";" in end of line 8. Then you get rid of this syntax error. Remember that each line should end with semicolon (";"). Your code looks like you perhaps forgot that.

    If you still have issues, could you please invest a bit of your time in describing your requirement in as much detail as possible! It would greatly help us in providing best possible assistance, therefore directly helping you achieve your goal. Thanks!

  • YOG Profile Picture
    414 on at

    Thanks Nikolaos,

    I have changed the code and tried entity but still no luck

    pastedimage1584098606606v1.png

    Here is what I am trying to do.

    I have custom data entity looking for CostAmount from LotTransaction screen (Sales ledger > Inquiries and Reports > Invoice > Invoice Journal > Invoice line > Stock > Lot transactions)

    In below screenshot, item has been invoiced  4 time from sales order. currently above code is pulling out 13,235.99 for each invoice, which is wrong. I want to modify code so I looks at Costamount by InvoiceId

    1273.err.JPG

     

  • Suggested answer
    nmaenpaa Profile Picture
    101,160 Moderator on at

    Unfortunately I don't see your second screenshot.

    Anyway your current code fetches two table buffers: CustInvoiceTrans and CustTrans. Later in the method you only use values from CustInvoiceTrans.

    Perhaps you should use CustInvoiceTrans::findCustInvoiceTrans method to find the record that you need? I don't know what information you have in your entity so I don't know what parameters you can provide in the search.

  • nmaenpaa Profile Picture
    101,160 Moderator on at

    Ok, now I see your screenshot. Unfortunately I don't even know what form is "Lot transactions"? Seems you are using D365 with British English (en-gb) where the terminology is a bit different than in en-us. Could you switch to en-us and tell me the name of the form, and more important, the name of the table. Also, is this table also the main data source for your entity? If not, which is?

  • YOG Profile Picture
    414 on at

    Hi Nicolaos,

    I have set my prefrences to en-us.

    screen is called 'lot transactions' and I am navigating (Account Receivable> Inquiries and Reports > Invoice > Invoice Journal > Invoice line > Inventory> Lot transactions)

    Table and Main Data source for my entity - CustInvoiceTrans

  • YOG Profile Picture
    414 on at

    Just to add up.

    here is a screenshot of CustInvoiceTrans Table where there are 4 invoices for same InventTransId

    1727.err.jpg

  • Verified answer
    nmaenpaa Profile Picture
    101,160 Moderator on at

    So, the data source for your entity is CustInvoiceTrans. And you want to find the current data source CustInvoiceTrans record, so that you can call some methods of that record and populate some virtual fields of your entity.

    Either your entity has, or you can add an internal field from CustInvoiceTrans.RecId.

    Then you can find the exact correct CustInvoiceTrans via CustInvoiceTrans::findRecId(this.RecId);

    Put this in the beginning of your postLoad() method and your other fields should get correct value.

  • YOG Profile Picture
    414 on at

    That worked. Thank you Nikolaos:)

    Here is the code that worked,

    pastedimage1584112454305v1.png

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
Martin Dráb Profile Picture

Martin Dráb 551 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

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

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 278 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans