Skip to main content

Notifications

Microsoft Dynamics AX (Archived)

Set Field

Posted on by Microsoft Employee

I am new in coding and i need a help .

I have this code as below 

AxLedgerJournalTable journalTable;
AxLedgerJournalTrans journalTrans;
container accCon;
container offSetCon;
LedgerJournalTable ledgerJournalTable;
ledgerJournalCheckPost ledgerJournalCheckPost;

journalTable = new AxLedgerJournalTable();
journalTrans = new AxLedgerJournalTrans();

//Journal Name
journalTable.parmJournalName('GenJrn');

journalTable.save();

journalTrans.parmJournalNum(journalTable.ledgerJournalTable().JournalNum);
journalTrans.parmTransDate(mkDate(04,05,2017));
journalTrans.parmAccountType(LedgerJournalACType::Ledger);

//LedgerDimension => Ledgeraccount, DAX 2009
accCon = ["500200", "500200",2,"Department","023","Costcenter","009"];
journalTrans.parmLedgerDimension(AxdDimensionUtil::getLedgerAccountId(accCon));

journalTrans.parmAmountCurDebit(200);

//OffsetLedgerDimension => OffsetLedgerAccount, DAX 2009

journalTrans.parmOffsetAccountType(LedgerJournalACType::Ledger);
offSetCon = ["510370", "510370", 1, "Department", "022"];
journalTrans.clearField(fieldNum(LedgerJournalTrans, OffsetLedgerDimension), false);
journalTrans.parmOffsetLedgerDimension(AxdDimensionUtil::getLedgerAccountId(offSetCon));

journalTrans.save();


//ledgerJournalCheckPost = ledgerJournalCheckPost::newLedgerJournalTable(journalTable.ledgerJournalTable(),NoYes::Yes);
//ledgerJournalCheckPost.run();

info(strFmt("Journal %1 created", journalTable.ledgerJournalTable().JournalNum));

I need to set the field values from the another table that has the values 

So Plz help me out.

*This post is locked for comments

  • Verified answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Set Field

    Hi Martin

    Thanks for the reply i am able to solve the Issue and for the suggestion You gave is quite helpful .

    journalTrans.clearField(fieldNum(LedgerJournalTrans, OffsetLedgerDimension), false);

    This need to be call after the Offset Dimension So it helped me solve the problem.

    I am able to create Offset Dimension now.

  • Martin Dráb Profile Picture
    Martin Dráb 230,149 Most Valuable Professional on at
    RE: Set Field

    Hi Rafe, please use the </> button in the rich formatting view to paste source code. Also, please remove unused variables and other things that don't add any value and merely make your code harder to understand. Here is the result:

    AxLedgerJournalTable journalTable = new AxLedgerJournalTable();
    AxLedgerJournalTrans journalTrans = new AxLedgerJournalTrans();
    container accCon;
    container offSetCon;
    
    //Journal Name
    journalTable.parmJournalName('GenJrn');
    
    journalTable.save();
    journalTrans.parmJournalNum(journalTable.ledgerJournalTable().JournalNum);
    journalTrans.parmTransDate(mkDate(04,05,2017));
    journalTrans.parmAccountType(LedgerJournalACType::Ledger);
    
    //LedgerDimension => Ledgeraccount, DAX 2009
    accCon = ["500200", "500200",2,"Department","023","Costcenter","009"];
    journalTrans.parmLedgerDimension(AxdDimensionUtil::getLedgerAccountId(accCon));
    journalTrans.parmAmountCurDebit(200);
    
    //OffsetLedgerDimension => OffsetLedgerAccount, DAX 2009
    journalTrans.parmOffsetAccountType(LedgerJournalACType::Ledger);
    offSetCon = ["510370", "510370", 1, "Department", "022"];
    
    journalTrans.clearField(fieldNum(LedgerJournalTrans, OffsetLedgerDimension), false);
    journalTrans.parmOffsetLedgerDimension(AxdDimensionUtil::getLedgerAccountId(offSetCon));
    journalTrans.save();
    
    info(strFmt("Journal %1 created", journalTable.ledgerJournalTable().JournalNum));

    Unfortunately I don't understand your requirement, therefore I can't help you. Consider elaborating what you need and what kind of problem you have with it.

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,149 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans