Hi,
I'm trying to get the two fields (Amount and Date) from each of the table by just checking if Date is blank in Table1 then fetch the record from Table2. The record from the both tables are selected using a common Primary Key.
*This post is locked for comments
Thanks it helped! :)
Hello, use below code in Cust. Ledger Entry - OnAfterGetRecord()
Cust. Ledger Entry - OnAfterGetRecord()
//>>Sbinesh - 09.15.17
CLEAR(AmountVariable);
CLEAR(DueDateVariable);
IF "CF_Promised to pay date" = 0D THEN BEGIN
CF_CollectionPaymentScheduleTable.RESET;
CF_CollectionPaymentScheduleTable.SETRANGE("Customer No.","Customer No.");
IF CF_CollectionPaymentScheduleTable.FINDFIRST THEN BEGIN
AmountVariable := CF_CollectionPaymentScheduleTable."Payment Amount";
DueDateVariable := CF_CollectionPaymentScheduleTable."Payment Date";
END;
END ELSE BEGIN
AmountVariable := "CF_Promised to pay amount";
DueDateVariable := "CF_Promised to pay date";
END;
//<<Sbinesh - 09.15.17
Documentation()
OnInitReport()
OnPreReport()
//Getting Company Details
CompanyInfoTable.RESET;
CompanyInfoTable.GET;
IF CompanyInfoTable.FINDFIRST THEN BEGIN
Companyaddress1 := CompanyInfoTable.Address;
Companyaddress2 := CompanyInfoTable."Address 2";
CompanyName1 := CompanyInfoTable.Name;
END;
//Company Details END
OnPostReport()
Customer - OnPreDataItem()
Customer - OnAfterGetRecord()
Customer - OnPostDataItem()
Cust. Ledger Entry - OnPreDataItem()
Cust. Ledger Entry - OnAfterGetRecord()
{Binesh Code.
IF Table1.Date_Field = 0D THEN BEGIN
IF Table2.GET(Table1.Primary_Key_Field) THEN BEGIN
Table1.Date_Field := Table2.Date_Field;
END;
END;}
IF "Cust. Ledger Entry".FINDFIRST THEN BEGIN
IF "Cust. Ledger Entry"."CF_Promised to pay date" = 0D THEN BEGIN
//REPEAT
CF_CollectionPaymentScheduleTable.RESET;
CF_CollectionPaymentScheduleTable.SETRANGE("Customer No.","Cust. Ledger Entry"."Customer No.");
IF CF_CollectionPaymentScheduleTable.FINDFIRST THEN BEGIN
AmountVariable := CF_CollectionPaymentScheduleTable."Payment Amount";
DueDateVariable := CF_CollectionPaymentScheduleTable."Payment Date";
//CurrReport.BREAK;
END;
//UNTIL CF_CollectionPaymentScheduleTable.NEXT=0;
END
{ELSE BEGIN
AmountVariable := "Cust. Ledger Entry"."CF_Promised to pay amount";
DueDateVariable := "Cust. Ledger Entry"."CF_Promised to pay date";
END;}
END;
Cust. Ledger Entry - OnPostDataItem()
CF_CollectionPaymentSchedule - OnPreDataItem()
CF_CollectionPaymentSchedule - OnAfterGetRecord()
CF_CollectionPaymentSchedule - OnPostDataItem()
Hello,
For better result post your original code,
In your posted code you are not getting Table2, So without seeing how could we give you solution.
This code is fetching only one entry of the Table1.
Is it because I'm using a variable of type date instead of Table1.Datefield.
I've even tried using REPEAT UNTIL after the second IF statement
The indentations is as follows
Customer
|_DateVariable
|_Table1(Field = Customer.No)
|_Table2(Field = Customer.No)
The condition is IF Table1.Date = 0D THEN DateVariable := Table2.Date
ELSE DateVariable := Table1.Date
Hello,
Design your report for data Item Table1
and write a code in
Table1 - OnAfterGetRecord()
IF Table1.Date_Field = 0D THEN BEGIN
IF Table2.GET(Table1.Primary_Key_Field) THEN BEGIN
Table1.Date_Field := Table2.Date_Field;
END;
END;
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,113 Super User 2024 Season 2
Martin Dráb 229,918 Most Valuable Professional
nmaenpaa 101,156