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
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
Post a Comment