Error while Deleting a table record in Ax 2009? Number Sequence Doesnot Exit?


I am using AX 2009… in Ledger journal Table and trans more than 4000 un wanted records transfer from some integration. Now i need to delete the records. By using Delete query it promp ’ Number Sequence Doesnot exist". how to solve this?


static void Deleteunwanted_payment(Args _args)


LedgerJournalTable LedgerJournalTable ;

LedgerJournalTrans LedgerJournalTrans ;


delete_from LedgerJournalTable where LedgerJournalTable .Name == ‘xxxxx’ && LedgerJournalTable .posted == NoYes::No;

delete_from LedgerJournalTrans where LedgerJournalTrans .Txt == ‘xxxxxxxxxx’ ;


If you get an error that you don’t understand, always check from where it was thrown. Often you can get there directly by double-clicking the error in infolog. If it doesn’t work, add a breakpoint to Info.add() - AX will stop when the message is written to infolog and you will be able to see the call stack in the debugger.

If it’s not enough for you to resolve the problem, please post the call stack here.

I think there is a delete action specified on ledgerjournalTable (wrt. ledgerjournalTrans) and in order to delete the record from ledgerJournalTable, firstly you need to delete the records from ledgerjournalTrans.

If its not allowing you to delete it using delete_from then try using ‘doDelete’ keyword for deleting [Or] try doing it from SQL.

I don’t think so - it would say that the record can’t be deleted because transactions exist, not that a number sequence doesn’t exist. It looks more like the deletion executes some code which tries to create a new record somewhere.

Using doDelete() or a direct SQL query would lead to data corruption (unless you handled all related data by additional X++/SQL code). It would likely cause much more serious problems than he’s trying to solve.

Yes martin you are correct, am not deleted first ledger table, i deleted first ledgertrans only .

dont know what exact problem is, but i deleted part by part by using where condition in journal number, its deleted…

Its solved