HI ,
We use AX2012 RTM version. I need to delete some open invoice journals and here is the simple code that I have in a job
static void deleteJournalNonService(Args _args) { LedgerJournalTable journalTable; select forUpdate firstonly journalTable index TypeNumIdx where journalTable.JournalNum == 'XXXXX'; if(journalTable) { ttsBegin; journalTable.delete(); ttsCommit; } info(strFmt('%1 has been deleted', journalTable.JournalNum)); }
It is failing at the line of code journaltable.delete();
When I debugged it is not finding the record in the LedgerJournalTable here (I see there is a record in the LedgerJournalTable) but for some reason it can't find the record in the below method
As I can't find the record then it is failing at the below line of code
and it finally throwing the error
Number sequence 0 doesn't exist. I am not sure what I am missing here. It finds the record my job when it executes select forupdate line of code but it is not when it is looking
in the below code during the debugging (which I already posted)
static LedgerJournalTable find(LedgerJournalId _ledgerJournalId, boolean _forUpdate = false) { LedgerJournalTable ledgerJournalTable; if (_ledgerJournalId) { ledgerJournalTable.selectForUpdate(_forUpdate); select firstonly ledgerJournalTable index TypeNumIdx where ledgerJournalTable.JournalNum == _ledgerJournalId; } return ledgerJournalTable; }
Am I missing somethin here or anyone ran into this scenario before?
Thanks.