Microsoft Dynamics NAV 2009 Automation


How can i code in aged account rec (Backdating) - ID: 17116. To automatically enter the aged as date as current date and the period type as 30 days? (So that i dont want to put these date during the running of the report). I am trying to automate this, if anyone can help me it will be very helpful for me…@@


If these variables are in request Form…You can write code on OnOpen Form of Request Form as

ageddate := WORKDATE;

periodtype := 30D;

Finally i automated the system. Thanks guys for your support.!!! cheers!!!

Thanks Mohana_cse06… you helped me alot.

Now i learnt to automate all the report. Cheers!!

Have Fun


Please Verify the post which solved your problem.

In the Same ID : 17116, How to code to set the useagingdate to “Posting Date” and to set UseCurrency to “DocumentCurrency”…


Posting Date and DocumentCurrency are from which record? If those are from Dataitem, we cannot have dataitem values in request form.

We can assign them in Dataitem onAftergetrecord.

If you are calling report through code, we have created a function and assign the values before calling the report.

Iam calling report through the code. Because i want to automate the report generation by giving to the job queue.

How can i set UseAgeDate And UseCurrency ?


Posting Date and DocumentCurrency are from which record?

Set them in OnAfterGetrecord of dataitem…


ItemLedgerEntry - OnAfterGetRecord

UseAgeDate := ItemLedgerEntry.“PostingDate”;

UseCurrency := ItemLedgerEntry.“Currency Code”;

Do i need to change anything in preReport() ?



Now when i run the report throught the job queue an error comes:

Error: You cannot base a date calculation on an undefined date format (OD) ?

Do you know what is this error?


Can you us the code what you have written adn where?

Inside Cust Ledger Entry (PreDataItem)

DtldCustLedgEntry.SETRANGE(“Posting Date”,CALCDATE(’+’ + FORMAT(‘1D’),PeriodStartDate[5]),PeriodStartDate[6]);

Inside OnPreReport

PeriodStartDate[6] := 31129999D;
PeriodStartDate[i] := CALCDATE(’-’ + FORMAT(‘30D’),PeriodStartDate[i + 1]);
ColumnHeader[i] :=
FORMAT(PeriodStartDate[5] - PeriodStartDate[i + 1] + 1) + ’ - ’ +
FORMAT(PeriodStartDate[5] - PeriodStartDate[i]) +
’ Days’;

Cust Ledger Entry (OnAfterGetRecord)

IF (EntryDate >= PeriodStartDate[i]) AND
(EntryDate <= CLOSINGDATE(CALCDATE(’-’ +FORMAT(‘1D’),PeriodStartDate[i + 1])))

Just Check the syntax of CALCDATE…

it should be like

CALCDATE(’<-30D>’),PeriodStartDate[i + 1]);

I can run the report. But when i put that in the job queue same error popups.

Error: You cannot base a date calculation on an undefined date format ?


Do i want to code anything in the report inorder to put the report in a job Queue?


may be the second parameter of CALCDATE is 0D while calling from the Job Queue…

check they are calculating the second parameters and based on which field.

Can Anyone give me a solution for this task:

I want to setup the report generation in a job queue, The report i use is ID17116 (Aged Acc. Rec (BackDating)).

operation: when the report runs in the job queue at a particular time, the aged acc rec of the customers should be able to sent a email attachment of the account receivable to the corresponding sales representative. Can anyone guide me to do this.

My Current Stage : Iam able to run the report manually without giving the inputs, and i can save this file to excel sheet when i run it manually. Now when i run in the job queue, it is poping with an error, (Undefined Date).