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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Implementing journal 'copy' functionality

(0) ShareShare
ReportReport
Posted on by 12

Hi,

I've a customized journal form and trying to incorporate the 'Copy' functionality,I've created the class with the following 'copy' code

Public void journalCopy(LedgerJournalTable _ledgerJournalTable)
{
LedgerJournalTable ledgerJournalTableinsert;
LedgerJournalTrans ledgerJournalTransOrig,ledgerJournalTransNew;
;

ttsBegin;
ledgerJournalTableinsert.data(_ledgerJournalTable);
ledgerJournalTableinsert.JournalNum = JournalTableData::newTable(LedgerJournalTable).nextJournalId();
ledgerJournalTableinsert.Posted = NoYes::No;
ledgerJournalTableinsert.insert();

while select ledgerJournalTransOrig
where ledgerJournalTransOrig.JournalNum == _ledgerJournalTable.JournalNum

{

ledgerJournalTransNew.data(ledgerJournalTransOrig);
ledgerJournalTransNew.JournalNum = ledgerJournalTableinsert.JournalNum;
ledgerJournalTransNew.insert();

}
info("");
ttsCommit;

}
on executing the above code the header details is getting copied but the line details does not,the line details form having the multiple ds like LedgerJournalTrans_Project,VendTransCashDisc etc.
so can anyone guide me on how to copy the line details ?

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Ludwig Reinhard Profile Picture
    Microsoft Employee on at

    Hi,

    You can take a look at the journals in the project module that have an out of the box copy functionality.

    Best regards

    Ludwig

  • VV-22040800-0 Profile Picture
    12 on at

    hi crispin ,how to re-write the code and which specific methods we've to call from AxLedgerJournalTrans to ' write'  and copy the Ledgerjournaltrans lines ?

  • VV-22040800-0 Profile Picture
    12 on at

    hi, using both the codes(code i've posted & link you've provided)  the data's are getting inserted at back end-table level but it's not getting reflected in form level.so what we've to do in form level ?

  • Suggested answer
    Rustem Galiamov Profile Picture
    8,072 on at

    Hi!

    I've create a job just to check. And journal's header and lines was created successful.

    static void Job175(Args _args)
    {
        LedgerJournalTable ledgerJournalTableinsert;
        LedgerJournalTrans ledgerJournalTransOrig,ledgerJournalTransNew;
        LedgerJournalTable _ledgerJournalTable = LedgerJournalTable::find('UNC-054212');
        ;
    
        ttsBegin;
        ledgerJournalTableinsert.data(_ledgerJournalTable);
        ledgerJournalTableinsert.JournalNum = JournalTableData::newTable(ledgerJournalTableinsert).nextJournalId();
        ledgerJournalTableinsert.Posted = NoYes::No;
        ledgerJournalTableinsert.insert();
    
        while select ledgerJournalTransOrig
            where ledgerJournalTransOrig.JournalNum == _ledgerJournalTable.JournalNum
        {
            ledgerJournalTransNew.data(ledgerJournalTransOrig);
            ledgerJournalTransNew.JournalNum = ledgerJournalTableinsert.JournalNum;
            ledgerJournalTransNew.insert();
        }
        info("");
        ttsCommit;
    }


    Screen-Shot-2018_2D00_09_2D00_07-at-22.14.13.png

    Screen-Shot-2018_2D00_09_2D00_07-at-22.14.13.png

    Did you have any customisation of journal lines form? 

  • VV-22040800-0 Profile Picture
    12 on at

    Yes it is a customised journal lines form with multiple data sources like LedgerJournalTrans_Project,VendTransCashDisc etc.Fields used in line details are from multiple tables,so how to copy the entire line details ?

  • Suggested answer
    Rustem Galiamov Profile Picture
    8,072 on at

    You need to know which data created in this tables while you create journal lines manually and then do the same steps in your code.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
CP04-islander Profile Picture

CP04-islander 26

#2
Michel ROY Profile Picture

Michel ROY 14

#3
imran ul haq Profile Picture

imran ul haq 8

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans