Skip to main content

Notifications

Finance | Project Operations, Human Resources, ...
Answered

Vendor account number is stored in the LedgerDimension format.

Posted on by 143

Hi everyone,

There is a form called BulkTagDestroy in which I created a field to insert the vendor account number through a dropdown, and I am retrieving that value in a variable called vendorAccountNum. Upon clicking a button, the details from that form are sent to the LedgerJournalTable, creating a new line there. Once created, I capture the journal batch number of the newly created line. Against that journal number, I need to go to the LedgerJournalTrans table and create a new record, adding the vendor details as well.

The problem I am facing is that in the LedgerJournalTrans, the vendor account number is stored in the LedgerDimension format. I am unsure how to retrieve it and from where. This is where I need assistance.

Environment : D365 F&O
Note : ledgerDimension2AccountNum this method are not available on my environment 

public void clicked()
    {
     ledgerJournalTrans ledgerJournalTransVendInvoice;

   
      vendorAccountNum =  BulkTagDestroy_AccountId.text(); 
       BulkTagDestroyDetailSel =  BulkTagDestroyDetail_DS.cursor(); 

      if ( BulkTagDestroyDetailSel)
      {

        makingCharges =  BulkTagDestroyDetailSel.makingCharges(); 
      }
  
      if ( BulkTagDestroy.JournalNum) 
      {
        error("Debit note is already generated for this entry.");
        return;
      }
      ttsBegin;
      try
      {
        ledgerJournalTable.JournalName = 'DBN';
        ledgerJournalTable.Name = "Note";
        ledgerJournalTable.initValue(); 

        ledgerJournalTable.insert();

        journalId = ledgerJournalTable.JournalNum;


        ledgerJournalTransVendInvoice.initValue();
       
       
        ledgerJournalTransVendInvoice.AccountType = LedgerJournalACType::Vend;
        ledgerJournalTransVendInvoice.Txt = "Debit Note - Vendor Invoice";
        ledgerJournalTransVendInvoice.AmountCurDebit = makingCharges;
	ledgerJournalTransVendInvoice.LedgerDimension =(Vedndor account number format)
        ledgerJournalTransVendInvoice.insert();
     
         BulkTagDestroy.JournalNum = journalId;
         BulkTagDestroy_ds.research(true);
        ttsCommit; 

      }
      catch (Exception::Error)
      {
        ttsAbort; 
       }
    }
Thanks for the help!! Feel free tp ask anything if you want clarity on the requirement.
  • Verified answer
    Ayushaman Profile Picture
    Ayushaman 143 on at
    Vendor account number is stored in the LedgerDimension format.
    Hi Antor,
     
    Thanks for the help! I used this for the problem and it working fine 
    ledgerJournalTransVendInvoice.LedgerDimension = LedgerDynamicAccountHelper::getDynamicAccountFromAccountNumber(vendorAccountNum, LedgerJournalACType::Vend);
    I also tried which you suggested the parmAccount but for this i think some methods are not defined on my environment .
            ledgerDimension = DimensionStorage::findByLedgerDimension(LedgerDimensionFacade::getDefaultDimension(vendorAccountNum));
            ledgerJournalTransVendInvoice.parmAccount(ledgerDimension.ledgerDimension());  
     
  • Suggested answer
    Anton Venter Profile Picture
    Anton Venter 18,676 Super User 2024 Season 2 on at
    Vendor account number is stored in the LedgerDimension format.
    Hello,
     
    Use the standard parmAccount method on the LedgerJournalTrans table.

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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Complete!

🔔 Be sure to subscribe to the new forums you are interested in to stay up to date! 🔔

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,902 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 229,302 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans