Skip to main content

Use temporary table as form datasource in D365FO

In this article, we will learn how we can use the temporary table as a form datasource in D365. In our scenario, we will populate the temporary table at runtime and bind it with the form datasource. firstly, we will pass an argument on the clicked event and write the form datasource  init  method to populate the data in it.  In our scenario we will work on the CustTable form, we will populate the customer group in the temporary table which we create on the selected customer while clicking the button. Step 1:  Create a new table of type TempDB and add two new fields i.e., CustGroupId and CustGroup. Step 2:  We will create a new form with the pattern (List Type), then add our previously created temporary table as a datasource, and then drag both the fields CustGroupId and CustGroup on the form grid part. After the form creation, we will also create the display menu item of type  form  and use our form on it. Step 3:  We will create an extension of the form ' CustTable ' and creat

Bank Cheque Report Customization

In this article, we will customize the Vendor Payment Journal form and the Bank Cheque Payment report in D365.

We have to add the custom field in the Vendor Payment Journal form, report and also customize the slip text area of the cheque printing report. To fulfill the requirement we will follow such steps:

Step 1:
We will create an extension of the LedgerJournalTrans table and then add the custom field Memo to it. 


Step 2:
We will create an extension of the form LedgerJournalTransVendPaym (Vendor Payment Journal) and drag the Memo field in the lines from the LedgerJournalTrans datasource.

Note: The custom field is successfully added to the form. Now we will add this field to the cheque report.

Step 3:
We will create COC of the determineReportMenuOutput method of the ChequeController class to call our custom design of the cheque report. 

[ExtensionOf(classStr(ChequeController))]
internal final class MDChequeController_Extension
{
    protected str determineReportMenuOutput(ChequeFormType _chequeFormType, BankChequeLayout _bankChequeLayout)
    {
        chequeReport = next determineReportMenuOutput(_chequeFormType, _bankChequeLayout);
        if (chequeReport == 'Cheque_US.Report')
        {
            chequeReport = ssrsReportStr(MDCheque_US, Report);
        }
        return chequeReport;
    }

}

Step 4:
We will create an extension of the ChequeTmp table and add a Memo field in this too.


Step 5:
We need to create the COC of method populateChequeTmp of class ChequeDP to fill the Memo field in the ChequeTmp table.
[ExtensionOf(classStr(ChequeDP))]
internal final class MDChequeDP_Extension
{
    protected void populateChequeTmp()
    {
        next populateChequeTmp();

        chequeTmp.Memo = LedgerJournalTrans::findRecId(tmpChequePrintout.TransactionRecId, false).Memo;
    }

}
Note: The Memo field has been successfully added to the form and report. Now we have to customize the slip text area of the report which is created dynamically. Before that, we would do some steps which are as below: 

Step 6:
We will create an extension of the BankChequePaymTrans table and then add the custom field Description to it. 


Step 7:
We need to create the COC of method InitBankChequePaymentTransFromVendTrans of class CustVendCheque to fill the Description field as this field has to be populated from the ledger transaction of vendor payment.
[ExtensionOf(classStr(CustVendCheque))]
internal final class MDCustVendCheque_Extension
{
    protected BankChequePaymTrans initBankChequePaymentTransFromVendTrans(SpecTrans _specTrans, CustVendPaym _custVendPaym, AmountCur _paymAmount)
    {
        BankChequePaymTrans bankChequePaymTrans;

        bankChequePaymTrans = next initBankChequePaymentTransFromVendTrans(_specTrans, _custVendPaym, _paymAmount);
        bankChequePaymTrans.Description = _custVendPaym.ledgerJournalTrans().Txt;

        return bankChequePaymTrans;
    }

}
Note: Now we will use this description field to customize the slip text area.

Step 8:  
Now we will create the COC of different methods of the CustVendChequeSlipTextCalculator class. 
[ExtensionOf(classStr(CustVendChequeSlipTextCalculator))]
internal final class MDCustVendChequeSlipTextCalculator_Extension
{
    public container determineSlipTextTitleAndEndLinesAdjustmentForChequeRecipientType(
        BankChequeTable _bankChequeTable,
        ChequeFormType _chequeFormType)
    {
        ChequeSlipTxt chequeSlipText;
        Counter endLines;
        BankAccountTable    bankAccountTable = BankAccountTable::find(_bankChequeTable.AccountID, false);

        [chequeSlipText, endLines] = next determineSlipTextTitleAndEndLinesAdjustmentForChequeRecipientType(_bankChequeTable, _chequeFormType);

        switch (_bankChequeTable.RecipientType)
        {
            case BankChequeRecipientType::Vend:
                chequeSlipText += (bankAccountTable
                                ? strFmt('\n%1 : %2', "@SYS40757", bankAccountTable.Name)
                                    : strFmt('\n%1 : ', "@SYS40757"));
                break;
        }
        return [chequeSlipText, endLines];
    }
	
    public container determineSlipTextTitleAndEndLinesAdjustmentForColumnHeaders(BankChequeTable _bankChequeTable, ChequeFormType _chequeFormType)
    {
        ChequeSlipTxt chequeSlipText;
        Counter endLines;

        [chequeSlipText, endLines] = next determineSlipTextTitleAndEndLinesAdjustmentForColumnHeaders(_bankChequeTable, _chequeFormType);

        switch (_chequeFormType)
        {
            case ChequeFormType::USStyle:
                chequeSlipText = strFmt(
                    '\n\n\n%1       %2        %3                           %4  %5\n\n',
                    "@SYS14204", "@SYS80056", "@SYS41042", "@SYS11818", "@SYS1943");
                endLines = -2;
                break;
        }
        return [chequeSlipText, endLines];
    }

    protected container determineSlipTextAndEndLinesAdjustmentForBankChequePaymTrans(BankChequePaymTrans bankChequePaymTrans)
    {
        ChequeSlipTxt chequeSlipText;
        Counter endLines;

        [chequeSlipText, endLines] = next determineSlipTextAndEndLinesAdjustmentForBankChequePaymTrans(bankChequePaymTrans);
        FromDate invoiceDate = bankChequePaymTrans.InvoiceDate;

        chequeSlipText = strFmt(
                '%1  %2  %3  %4  %5\n',
                strLFix(bankChequePaymTrans.InvoiceId, 12),
                strLFix(date2StrUsr(invoiceDate), 10),
                strLFix(bankChequePaymTrans.Description, 36),
                strRFix(num2str(-bankChequePaymTrans.InvoiceAmountCur, 0, 2, -1, -1), 12),
                strRFix(num2str(-bankChequePaymTrans.PaymentAmountCur, 0, 2, -1, -1), 14));

        endLines = -1;

        return [chequeSlipText, endLines];
    }


    protected CustVendChequeSlipTextCalcDeterminSlipTextForTotalReturn determineSlipTextTitleAndEndLinesForSubTotalOrTotal(CustVendChequeSlipTextCalcDeterminSlipTextForTotalParameters _args)
    {
        CustVendChequeSlipTextCalcDeterminSlipTextForTotalReturn totalReturn = CustVendChequeSlipTextCalcDeterminSlipTextForTotalReturn::construct();

        totalReturn = next determineSlipTextTitleAndEndLinesForSubTotalOrTotal(_args);

        totalReturn.chequeSlipTxt = strFmt('\n%1 %2', strLFix(_args.chequeSlipTxtLabel, 75), num2str(_args.TotalAmountCur, 16, 2, -1, -1));
        totalReturn.endLines = -1;

        return totalReturn;
    }

}
Note: The keyword 'strLFix' and 'strRFix' is used to add the padding from the left and right of the string.
The following methods description are as below:

  • determineSlipTextTitleAndEndLinesAdjustmentForChequeRecipientType:
    In this method, we have concatenated the Bank Account details in the slip text area.

  • determineSlipTextTitleAndEndLinesAdjustmentForColumnHeaders:
    In this method, we have customized the header section of the lines of slip text and added the description label.

  • determineSlipTextAndEndLinesAdjustmentForBankChequePaymTrans:
    In this method, we have customized the lines of slip text and also added the description field.

  • determineSlipTextTitleAndEndLinesForSubTotalOrTotal:
    In this method, need to move the total amount of Sliptext to a bit of the right side to adjust.

Comments

Popular posts from this blog

Use temporary table as form datasource in D365FO

In this article, we will learn how we can use the temporary table as a form datasource in D365. In our scenario, we will populate the temporary table at runtime and bind it with the form datasource. firstly, we will pass an argument on the clicked event and write the form datasource  init  method to populate the data in it.  In our scenario we will work on the CustTable form, we will populate the customer group in the temporary table which we create on the selected customer while clicking the button. Step 1:  Create a new table of type TempDB and add two new fields i.e., CustGroupId and CustGroup. Step 2:  We will create a new form with the pattern (List Type), then add our previously created temporary table as a datasource, and then drag both the fields CustGroupId and CustGroup on the form grid part. After the form creation, we will also create the display menu item of type  form  and use our form on it. Step 3:  We will create an extension of the form ' CustTable ' and creat

Deploy Package to LCS for Dynamics 365 Finance & Operation

In this blog, we will learn how to extract deployable packages from the Azure DevOps Pipeline and then deploy the specific package to the LCS Standard Acceptance Testing (UAT) Environment. Extract Package from Pipeline and Upload to LCS Step 1 : Go to Azure DevOps ->  Pipelines ->  Recent ->  10.0.37-Gated Build Step 2 : Go to recent check-in Step 3 : Go to published Step 4 : Click on AXDeployableRuntime_7.0.7068.67_2023.12.6.1.zip Step 5 : After downloading the Deployable package Go to Lifecycle Services -> Asset library Step 6 : Go to Software deployable package Step 7 : Navigate and select Software deployable package and select the  + button to add the package to the folder and confirm. Refresh the screen and wait for the package to get validated, the tick will appear once validated. Note: The package will be successfully uploaded to the LCS Environment after the above step. Now we will deploy this package to the Standard Acceptance Testing (UAT) environment. Deploy Pack

Using Complex Ranges on Date Fields in Query

In some of the scenarios,  we want to filter out the from-date and to-date ranges on the basis of different fields and  we are not getting the outcome in which we want to apply the AND/OR clause between date ranges on different date fields and we cannot acquire this result using out-of-the-box query classes. So we have applied complex date ranges to get the desired outcome: void initQuery() { Query                          query; QueryRun                queryRun; QueryBuildDataSource      qbdsProjPeriodLine; QueryBuildRange rangePeriodId; query = queryRun.query(); qbdsProjPeriodLine = query.dataSourceTable(tableNum(ProjPeriodLine)); if (periodFrom && periodTo) { qbdsProjPeriodLine.addRange(fieldNum(ProjPeriodLine, PeriodFrom)).value(strFmt('((%1.%2 >= %4) && (%1.%3 <= %5))',                                  qbdsProjPeriodLine.name(),