
I have created a report with C/AL Code that I am using to create three fields that do not exist in NAV. The reason for the fields to be created in this way is they are needed to be a part of the .csv file that is sent to the bank. This is for positive pay situation so we can go paperless with checks. The fields as easy as it was to create and get it to populate it is causing some issues with outputting the file automatically. As I have found a post from Cloud-Fronts on how to export a csv file from a report, it does not cover the need to pass text fields that you have created. My question is this possible? The error I am getting is that in the c/al code when I save the error is
A field from a record variable was expected. For example:
Record.Field
Customer.Name
The code that is giving the error is (This is just a snipet of the entire Code. This is where the issue throws the error.
LOCAL MakeExcelDataHeader()
ExcelBuffer.AddColumn("Check Ledger Entry".FieldCaption("Always28"),FALSE,'',TRUE,FALSE,TRUE,'',ExcelBuffer."Cell Type"::Text);
Full Code
OnInitReport()
PrintToExcel:=TRUE; //ADDED FOR CREATE OF EXCELBOOK
OnPreReport()
ExcelBuffer.DELETEALL; //ADDED FOR CREATE OF EXCELBOOK
OnPostReport()
IF PrintToExcel THEN //ADDED FOR CREATE OF EXCELBOOK
CreateExcelBook;
Check Ledger Entry - OnPreDataItem()
MakeExcelDataHeader; //ADDED FOR CREATE OF EXCELBOOK
Check Ledger Entry - OnAfterGetRecord()
"Check Ledger Entry".Description:= (DELCHR("Check Ledger Entry".Description, '=' , ','));
IF "Check Ledger Entry".Amount <> 0 THEN
AccountNo := '267104';
IF "Check Ledger Entry"."Entry Status" = 2 THEN
TransCode := 'VD';
IF "Check Ledger Entry"."Entry Status" = 3 THEN
TransCode := 'IA';
IF "Check Ledger Entry"."Entry Status" = 4 THEN
TransCode := 'VA';
Always28:= '28';
IF PrintToExcel THEN //ADDED FOR CREATE OF EXCELBOOK
MakeExcelDataBody;
Check Ledger Entry - OnPostDataItem()
LOCAL MakeExcelInfo()
LOCAL MakeExcelDataHeader()
ExcelBuffer.AddColumn("Check Ledger Entry".FIELDCAPTION("Check No."),FALSE,'',TRUE,FALSE,TRUE,'',ExcelBuffer."Cell Type"::Text); //ADDED FOR CREATE OF EXCELBOOK
ExcelBuffer.AddColumn("Check Ledger Entry".FIELDCAPTION("Check Date"),FALSE,'',TRUE,FALSE,TRUE,'',ExcelBuffer."Cell Type"::Text); //ADDED FOR CREATE OF EXCELBOOK
ExcelBuffer.AddColumn("Check Ledger Entry".FIELDCAPTION("Amount"),FALSE,'',TRUE,FALSE,TRUE,'',ExcelBuffer."Cell Type"::Text); //ADDED FOR CREATE OF EXCELBOOK
ExcelBuffer.AddColumn("Check Ledger Entry".FIELDCAPTION("Always28"),FALSE,'',TRUE,FALSE,TRUE,'',ExcelBuffer."Cell Type"::Text); //ADDED FOR CREATE OF EXCELBOOK
ExcelBuffer.AddColumn("Check Ledger Entry".FIELDCAPTION("AccountNo"),FALSE,'',TRUE,FALSE,TRUE,'',ExcelBuffer."Cell Type"::Text); //ADDED FOR CREATE OF EXCELBOOK
ExcelBuffer.AddColumn("Check Ledger Entry".FIELDCAPTION("TransCode"),FALSE,'',TRUE,FALSE,TRUE,'',ExcelBuffer."Cell Type"::Text); //ADDED FOR CREATE OF EXCELBOOK
ExcelBuffer.AddColumn("Check Ledger Entry".FIELDCAPTION("Description"),FALSE,'',TRUE,FALSE,TRUE,'',ExcelBuffer."Cell Type"::Text); //ADDED FOR CREATE OF EXCELBOOK
LOCAL MakeExcelDataBody()
ExcelBuffer.NewRow; //ADDED FOR CREATE OF EXCELBOOK
ExcelBuffer.AddColumn("Check Ledger Entry"."Check No.",FALSE,'',FALSE,FALSE,FALSE,'',ExcelBuffer."Cell Type"::Text); //ADDED FOR CREATE OF EXCELBOOK
ExcelBuffer.AddColumn("Check Ledger Entry"."Check Date",FALSE,'',FALSE,FALSE,FALSE,'',ExcelBuffer."Cell Type"::Text); //ADDED FOR CREATE OF EXCELBOOK
ExcelBuffer.AddColumn("Check Ledger Entry"."Amount",FALSE,'',FALSE,FALSE,FALSE,'',ExcelBuffer."Cell Type"::Text); //ADDED FOR CREATE OF EXCELBOOK
ExcelBuffer.AddColumn("Check Ledger Entry"."Always28",FALSE,'',FALSE,FALSE,FALSE,'',ExcelBuffer."Cell Type"::Text); //ADDED FOR CREATE OF EXCELBOOK
ExcelBuffer.AddColumn("Check Ledger Entry"."AccountNo",FALSE,'',FALSE,FALSE,FALSE,'',ExcelBuffer."Cell Type"::Text); //ADDED FOR CREATE OF EXCELBOOK
ExcelBuffer.AddColumn("Check Ledger Entry"."TransCode",FALSE,'',FALSE,FALSE,FALSE,'',ExcelBuffer."Cell Type"::Text); //ADDED FOR CREATE OF EXCELBOOK
ExcelBuffer.AddColumn("Check Ledger Entry"."Description",FALSE,'',FALSE,FALSE,FALSE,'',ExcelBuffer."Cell Type"::Text); //ADDED FOR CREATE OF EXCELBOOK
LOCAL CreateExcelBook()
Hello Troy- We currently do not have dedicated Dev support via the Dynamics NAV forums, but I wanted to provide you some additional resources to assist. If you need assistance with debugging or coding I would recommend discussing this on one of our communities.
dynamicsuser.net/.../developers
I will open this up to the community in case they have something to add.