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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

Bank payment voucher main description

(1) ShareShare
ReportReport
Posted on by 222
Hi All,
 
I am generating Bank Payment Voucher by X++ code and its working fine. But now I got the requirement to set the main description so,  have set the value in Name field of LedgerJournalTable  table. But unfortunaly when voucher is created and I saw the voucher view that custom description was not there and it is going to display the default description "Bank Payment Voucher". How I can fix the issue. 
 
Here is my code to create the voucher. 
 
    public LedgerJournalTable createPJHeader(JournalNameId journalName, str vouDescription = "" )    
    {
        select firstonly ledgerJournalName
        where ledgerJournalName.JournalName == journalName && ledgerJournalName.JournalType == LedgerJournalType::Payment;
        // Header        ledgerJournalTable = null;
        ledgerJournalTable.company(curExt());
        ledgerJournalTable.JournalName = journalName;
        ledgerJournalTable.initFromLedgerJournalName();
        ledgerJournalTable.NumberSequenceTable = ledgerJournalName.NumberSequenceTable;
        ledgerJournalTable.Name = vouDescription;
        ledgerJournalTable.insert();
        return ledgerJournalTable;
    }
I have the same question (0)
  • Martin Dráb Profile Picture
    238,149 Most Valuable Professional on at
    Use the debugger to find out what's going on in your code.
     
    An explanation would be that the value gets overwritten in insert(), but according to code there (in F&O, at least), the value of Name field is initialized from LedgerJournalName only if it's empty. Maybe you believe that your vouDescription variable has a value but it doesn't. Use the debugger to verify it.

    By the way, what is your version of AX?
  • nbhatti2001 Profile Picture
    222 on at
    Hi Martin, 
     
    I am using D365FO.
     
    I have debug and its verified that vouDescription has the value. I have tried the follwoing code and its worked. But I don't think it should be fixed like this.  I think this is ture that value is going to re-intialize in insert method. But how to avoid it, I am looking for. If you have some suggestion please suggest. 
     
        public LedgerJournalTable createPJHeader(JournalNameId journalName, str vouDescription = "" )
        {
            select firstonly ledgerJournalName
                where ledgerJournalName.JournalName == journalName && ledgerJournalName.JournalType == LedgerJournalType::Payment;
            // Header
            ledgerJournalTable = null;
            ledgerJournalTable.company(curExt());
            ledgerJournalTable.JournalName = journalName;
            ledgerJournalTable.initFromLedgerJournalName();
            ledgerJournalTable.NumberSequenceTable = ledgerJournalName.NumberSequenceTable;
            ledgerJournalTable.Name = vouDescription;
            ledgerJournalTable.insert();
            ledgerJournalTable.Name = vouDescription;
            ttsbegin;
            ledgerJournalTable.update();
            ttscommit;
            return ledgerJournalTable;
        }
  • Martin Dráb Profile Picture
    238,149 Most Valuable Professional on at
    Moved from Dynamics AX forum.
     
    You don't have to guess that happens inside insert() (and its extensions) - you can use the debugger to actually see it.
     
    You're right; your workaround isn't something you should use in the real implementation.
  • nbhatti2001 Profile Picture
    222 on at
    Hi Martin, 
     
    What do you think if there is some extension then it should apply when I am creating Bank Payment from frontend. But whenever I am creating Bank Payment from frontend its working fine. It accept the description as given.
     
    Thanks.
  • Martin Dráb Profile Picture
    238,149 Most Valuable Professional on at
    I can't comment on what extensions you may have in your environment. If I was you, I wouldn't try to guess what's overwriting the value; I would look at the actual code.
  • Verified answer
    nbhatti2001 Profile Picture
    222 on at
    It was the issue with the code which I was using. Here is the code which solve the issue.

        public LedgerJournalTable createPJHeader(JournalNameId journalName, str vouDescription = "" )
        {
            LedgerJournalTableData jourTableData;
            // Header
            ledgerJournalTable = null;
            ledgerJournalTable.company(curExt());
            ledgerJournalTable.JournalName = journalName;
            jourTableData = JournalTableData::newTable(ledgerJournalTable);
            ledgerJournalTable.JournalNum = jourTableData.nextJournalId();
            ledgerJournalTable.JournalType = LedgerJournalType::Payment;
            ledgerJournalTable.Name = vouDescription;
            ledgerJournalTable.insert();
            return ledgerJournalTable;
        }

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

Season of Giving Solutions is Here!

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
Abhilash Warrier Profile Picture

Abhilash Warrier 732 Super User 2025 Season 2

#2
André Arnaud de Calavon Profile Picture

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

#3
Martin Dráb Profile Picture

Martin Dráb 289 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans