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

Number of vouchers posted to the journal: 1

(0) ShareShare
ReportReport
Posted on by 1,836

I have created vendor payment journal posting code and after running it show following message "Number of vouchers posted to the journal: 1"  and i want to create vendor payment journal using x++ , i am posting may code below can anybody plz help as  i am complete beginner to d365.

public static void main(Args _args)
{
VendTrans VendTrans,VendTransBank;

Ledgerjournalname ledgerjournalname;

LedgerjournalTable LedgerjournalTable;

LedgerjournalTrans LedgerjournalTrans;

LedgerjournalCheckPost LedgerjournalCheckPost;

NumberSeq numberSeq;
BanKACCOUNTTABLE BankAccountTable;
;

select firstOnly ledgerjournalname;

select firstOnly VendTrans where VendTrans.AccountNum == "1001";

select firstOnly VendTransBank where VendTrans.AccountNum == "1001";

select AccountID from BankAccountTable join VendTransBank where
BankAccountTable.AccountID == VendTransBank.CompanyBankAccountId
&& VendTransBank.AccountNum == "1001";


// create journal

ttsBegin;

LedgerjournalTable.JournalName = ledgerjournalname.JournalName;

LedgerjournalTable.initFromLedgerJournalName();

LedgerjournalTable.JournalNum = JournalTableData::newTable(LedgerjournalTable).nextJournalId();

LedgerjournalTable.insert();

ttsCommit;

ttsBegin;

// create journal Lines

numberSeq = NumberSeq::newGetVoucherFromId((ledgerjournalname.NumberSequenceTable));

LedgerjournalTrans.Voucher = numberSeq.voucher();

LedgerjournalTrans.JournalNum = LedgerjournalTable.JournalNum;

LedgerjournalTrans.CurrencyCode = "USD";

LedgerjournalTrans.ExchRate = Currency::checkExist(LedgerjournalTrans.CurrencyCode);

LedgerjournalTrans.AccountType = LedgerJournalACType::Vend;

LedgerjournalTrans.parmAccount(VendTrans.AccountNum,LedgerjournalTrans.AccountType);

LedgerjournalTrans.Txt = 'Vendor payment journal demo';

LedgerjournalTrans.AmountCurCredit = 1000;

LedgerjournalTrans.TransDate = systemDateGet();

LedgerjournalTrans.OffsetAccountType = LedgerJournalACType::Bank;


LedgerjournalTrans.offsetLedgerDimension= LedgerDynamicAccountHelper::getDynamicAccountFromAccountNumber(VendTransBank.CompanyBankAccountId, LedgerJournalACType::Bank);

LedgerjournalTrans.DefaultDimension = VendTrans::find(VendTrans.RecId).DefaultDimension;

LedgerjournalTrans.OffsetDefaultDimension = VendTrans::find(VendTrans.RecId).DefaultDimension;

LedgerjournalTrans.LedgerDimension = LedgerDynamicAccountHelper::getDynamicAccountFromAccountNumber(VendTrans.AccountNum, LedgerJournalACType::Vend);

LedgerjournalTrans.insert();

ttsCommit;

// posting

LedgerjournalCheckPost = LedgerjournalCheckPost::newLedgerJournalTable(LedgerjournalTable,NoYes::Yes);

LedgerjournalCheckPost.run();
}

}

I have the same question (0)
  • Verified answer
    AnithaEswaran Profile Picture
    2,032 on at
    RE: Number of vouchers posted to the journal: 1

    Please update as 'Verified' if the solution is working

  • Dineshkarlekar Profile Picture
    1,836 on at
    RE: Number of vouchers posted to the journal: 1

    hi ,Andre

    thanks for reply,

    when I manually  post the journal I get "Number of vouchers posted to the journal: 1" and "Operation completed" its system generated  I am ok with it my concern was my code was not working but now journal creation and posting is done and the code is working properly.

  • Dineshkarlekar Profile Picture
    1,836 on at
    RE: Number of vouchers posted to the journal: 1

    hi, Anitha

    I manually  posted the journal the result was same . I am ok with it I will try to info with the post logic . Thanks for helping me out.

  • Verified answer
    André Arnaud de Calavon Profile Picture
    299,022 Super User 2025 Season 2 on at
    RE: Number of vouchers posted to the journal: 1

    Hi Dinesh,

    What exact message do you get if you manually create the journal with 1 line and do the posting? Then you will get the same information message including a line "Operation completed". In my opinion, there is no issue with the message "Number of vouchers posted to the journal: 1". This is a standard message from the application.

  • AnithaEswaran Profile Picture
    2,032 on at
    RE: Number of vouchers posted to the journal: 1

    Usually we get this message on posting from the form.

    you have 2 options :

    1. Manually post the journal and debug from where this info is displayed.

    (or)

    2.  After the post logic in your code, check if the journal is posted and if yes, display the message.

  • Dineshkarlekar Profile Picture
    1,836 on at
    RE: Number of vouchers posted to the journal: 1

    class RunnableClass16
    {
        /// 
        /// Runs the class with the specified arguments.
        /// 
        /// The specified arguments.
        public static void main(Args _args)
        {
            VendTrans               VendTrans,VendTransBank;
    
            Ledgerjournalname       ledgerjournalname;
    
            LedgerjournalTable      LedgerjournalTable;
    
            LedgerjournalTrans      LedgerjournalTrans;
    
            LedgerjournalCheckPost  LedgerjournalCheckPost;
    
            NumberSeq               numberSeq;
            BanKACCOUNTTABLE		BankAccountTable;
            ;
    
            //select firstOnly ledgerjournalname;
    
            select firstonly ledgerJournalName
            where ledgerJournalName.JournalName == ledgerjournalname.JournalName &&
                ledgerJournalName.JournalType == LedgerJournalType::Payment;
    
            select firstOnly VendTrans where VendTrans.AccountNum == "1001";
    
            select firstOnly VendTransBank where VendTrans.AccountNum == "1001";
    
            select AccountID from BankAccountTable  join VendTransBank
    		  where VendTransBank.AccountNum == "1001"
              &&  BankAccountTable.AccountID == VendTransBank.CompanyBankAccountId
               ;
    
    
            // create journal
    
            ttsBegin;
    
            LedgerjournalTable.JournalName          =   ledgerjournalname.JournalName;
    
            LedgerjournalTable.initFromLedgerJournalName();
    
            LedgerjournalTable.JournalNum           =   JournalTableData::newTable(LedgerjournalTable).nextJournalId();
    
            LedgerjournalTable.insert();
    
            ttsCommit;
    
    
    
            ttsBegin;
    
            // create journal Lines
    
            numberSeq                               =   NumberSeq::newGetVoucherFromId((ledgerjournalname.NumberSequenceTable));
    
            LedgerjournalTrans.Voucher              =   numberSeq.voucher();
    
            LedgerjournalTrans.JournalNum           =   LedgerjournalTable.JournalNum;
    
            LedgerjournalTrans.CurrencyCode         =   "USD";
    
            LedgerjournalTrans.ExchRate             =   Currency::checkExist(LedgerjournalTrans.CurrencyCode);
    
            LedgerjournalTrans.AccountType          =   LedgerJournalACType::Vend;
    
            LedgerjournalTrans.parmAccount(VendTrans.AccountNum,LedgerjournalTrans.AccountType);
    
            LedgerjournalTrans.Txt                  =   'Vendor payment journal demo';
    
            LedgerjournalTrans.AmountCurCredit      =   1000;
    
            LedgerjournalTrans.TransDate            =   systemDateGet();
    
            LedgerjournalTrans.OffsetAccountType    =   LedgerJournalACType::Bank;
    
    
            LedgerjournalTrans.offsetLedgerDimension=    LedgerDynamicAccountHelper::getDynamicAccountFromAccountNumber(VendTransBank.CompanyBankAccountId, LedgerJournalACType::Bank);
    
            LedgerjournalTrans.DefaultDimension     =  VendTrans::find(VendTrans.RecId).DefaultDimension;
    
            LedgerjournalTrans.OffsetDefaultDimension =  VendTrans::find(VendTrans.RecId).DefaultDimension;
    
            LedgerjournalTrans.LedgerDimension      =  LedgerDynamicAccountHelper::getDynamicAccountFromAccountNumber(VendTrans.AccountNum, LedgerJournalACType::Vend);
    
            LedgerjournalTrans.insert();
    
            ttsCommit;
    
            // posting
    
            LedgerjournalCheckPost      =   LedgerjournalCheckPost::newLedgerJournalTable(LedgerjournalTable,NoYes::Yes);
    
            LedgerjournalCheckPost.run();
        }
    
    }

    here is my code to create vendor payment journal .

  • Dineshkarlekar Profile Picture
    1,836 on at
    RE: Number of vouchers posted to the journal: 1

    hi , Anitha

    you are right the journal type was missing in my code . I was trying to do this for so many days , thanks for helping me out.

           select firstonly ledgerJournalName

           where     ledgerJournalName.JournalName ==    ledgerjournalname.JournalName

           &&         ledgerJournalName.JournalType   ==    LedgerJournalType::Payment ;

    I had done these changes in code as you suggested and my journal is created and its posting getting done in vendor payment journal but I am not getting why the info message is "Number of vouchers posted to the journal: 1" , when I run my code the info message  should be like " journal created " or    " new journal  posted" .

    journalCreated.PNG

  • AnithaEswaran Profile Picture
    2,032 on at
    RE: Number of vouchers posted to the journal: 1

    I think you have missed to include JournalType in your code. Else, by default the journal is created in General journal.

    You are only selecting firstonly in Journalname. Can you include the condition to select JournalType as well?

  • Dineshkarlekar Profile Picture
    1,836 on at
    RE: Number of vouchers posted to the journal: 1

    yes Anitha,

    i have been checking there , for the journal number , and voucher number but its not there , i have selected  "posted ".

    vocher.PNG

    journal-num.PNG

    8078.output.PNG

  • AnithaEswaran Profile Picture
    2,032 on at
    RE: Number of vouchers posted to the journal: 1

    Are you checking here with 'Posted' selectd

    pastedimage1655113653213v1.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…

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,206

#2
André Arnaud de Calavon Profile Picture

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

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 596 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans