export data's to file

You are doing it in wrong way.

You have to simply call


in onDelete trigger of Transaction Header Table

Set TableNo. property of Codeunit 59999 to Transaction Header

Simply write

MESSAGE(’%1’,“Store No.”);

in OnRun Trigger of codeunit59999

Please do it in Test Database…


I think I should be little more expert. to know where exactly to pass the codes.

Now my codeunit has only one trigger, that is OnRun. There are some other function that I have added, those are functio1 and function2. These 2 function call is being decided in OnRun trigger based on some conditions. Now I have disabled(commented) the call to these 2 functions(functio1 and function2) to test our CODEUNIT.RUN(59999,Rec); command.

Now, my OnRun section includes the codes as below:



VTextFileName:=‘C:\Transaction Header\99001472.txt’;




But, there is no OnDelete trigger. Please do not mide if I ask you ‘do I have to create this OnDelete trigger manually ? or it should be there by default once I create a new code unit’? [;)]

It was not when I started.

Please read answers carefully…

Hi Mohana,

I set it like that. I gone to transaction header table’s code unit and in ondelete i put CODEUNIT.RUN(59999.Rec);

and in my 59999 code unit property, I set ‘TableNo’ property to 'Transaction Header’.

In my code unit, I wrote only, MESSAGE(’%1’,“Store No.”);

But, still the same message keeps coming saying that 'The codeunit th NY optimization code must be called with a Transaction Header record’.

I hope you have written CODEUNIT.RUN(59999.Rec); in OnDelete trigger of transaction header table only

Are you running the Codeunit manually?

You have to delete any record in transaction header table then the Codeunit 59999 will be called automatically.

try it in Test database.

yes, this code unit is single and needs to be called manually.

The basic requirement of this code unit is to delete transaction header table manually by running it.

Do you want to delete all records from transaction Header table by running this codeunit?

not all the records, but, old records.

why I am creating this is, store’s DB gets bulk frequently, and to get rid of optimizing their DB, I am planning to put this functionality to their Navision.

i set the date as 3 month’s back and the data’s older than that needs to be deleted.

It is not advisable to delete records from navision tables…

But if it has no impact on database then …

Sorry, i misunderstood your requirement.

Delete code from OnDelete trigger of Transaction Header database.

Delete table No. property of codeunit 59999.

You need to put filter on date field which you want


TransactionHeader.SETFILTER(“Date Filter”,’…%1’,);

IF Transactionheader.FINDSET THEN


Message(’%1’,Transactionheader.“Store No.”);

UNTIL Transactionheader.Next = 0;


I have done through another way. I created one dataport to export the data’s from those table.

Then I called this dataport inside my codeunit just before the code to delete it.

It’s done, thank you mohana, and did you nitice my another query in this:




Hi Mohana,

Is there any way to use the dataport to append the data’s in the file instead of replacing the older file ??