Skip to main content

Notifications

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

Vendor account number is stored in the LedgerDimension format.

(1) ShareShare
ReportReport
Posted on by 161

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 161 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,788 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

News and Announcements

Announcing Category Subscriptions!

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,359 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,370 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans