Sunday, August 9, 2020

Insert GeneralJournal through X++ , D365 (Insert JV through Code)

 here is the code to insert GeneralJournal through code

Paramenter are

1) Journal Name (_journalName ) : the name of the journal you want to add with

2) Account (_debit ) : the account is the int64 field representing account base on the Account type which you can change in code.

3) OffsetAcount (_Credit) : the account is the int64 field representing account base on the Account type which you can change in code.

4) Description (_description ) : the description you want to add in journal

(Note: I added 100 in debit)

private void insertGeneralJournal(str _journalName , int64 _debit , int64 _credit , str _description = "")

    {

        MCRLedgerJournal        journalTable;

        LedgerJournalTable      ledgerJournalTable;

        journalTable = new MCRLedgerJournal_Daily(LedgerJournalType::Daily,_journalName);

        //Creates the journal header table

        ledgerJournalTable = journalTable.createLedgerJournalTable(_journalName);


        journalTable.parmLedgerJournalTable(ledgerJournalTable);

        journalTable.parmMCRCCGeneralLedgerId();

        journalTable.parmLedgerAccountType(LedgerJournalACType::Ledger);

        journalTable.parmLedgerOffsetAccountType(LedgerJournalACType::Ledger);

        //    journalTable.parmExchRate(_revenuePosting.ExchRate);

        //   journalTable.parmCurrencyCode(_revenuePosting.CurrencyCode);

        journalTable.parmLineNum();

        journalTable.parmLedgerAccount(_debit);

        journalTable.parmledgerOffsetAccount(_credit);

        journalTable.parmTransDate(today());

        journalTable.parmTransTxt(_description );

        //create the journal trans table

        journalTable.createLedgerJournalTrans(abs(100),0,LedgerJournalACType::Ledger);

       

        info(strFmt("journal number %1 has been generated as assessment fee for student %2" ,         ledgerJournalTable.JournalNum , prospectStudentAssessmentTable.prospectStudentId));

      //To Post generalJournal

        ledgerjournalcheckpost      post ;

        post =  LedgerJournalCheckPost::newLedgerJournalTable(ledgerJournalTable,true,true);


        // post = new LedgerJournalcheckPost::newLedgerJournalTable(table,NoYes::Yes,NoYes::Yes);

        post.run();

    }

dimensionhierarchyhelper::getHierarchyTypeByAccountType has been incorrectly called

 This error accurred in my case when I add a field LedgerDimension Or Offset Ledger dimension in cutom table and used it in the form . In the segmented entry control I set the Accout Type field as Ledger Dimension as You can see in the below Image. the error occurred due to this prperty.

You need to set this property with the Enum type field AccountType in mmy case with enum property "LedgerJournalACType" . as shown in below image.

AccountType field:


Change SSRS Report Design Based On Condition , D365 ,X++

 To change Sales Invoice control document's design based on condition use following code. Here I have created COC of salesInvoiceControl...