Tuesday, December 1, 2015

Manually generate Number Sequence & release unused

The below code is to manually generate the number from the Number Sequence code:

numberSeq = NumberSeq::newGetNumFromCode(BankAccountTable::findByLedgerDimension(this.OffsetLedgerDimension).FundsTransferRefNum);

Sometimes we face this situation where number sequence doesn't release the unused numbers even if the Number sequence is configured as "Continuous". In that case we can use the below code:

NumberSeq::releaseNumber(NumberSequenceTable::findByNaturalKey(BankAccountTable::findByLedgerDimension(this.OffsetLedgerDimension).FundsTransferRefNum).RecId, ledgerJournalTrans_FundsTransfer.FundsTransferRefNum);

4 comments:

  1. Hi,

    Where to write this code
    NumberSeq::releaseNumber(NumberSequenceTable::findByNaturalKey(BankAccountTable::findByLedgerDimension(this.OffsetLedgerDimension).FundsTransferRefNum).RecId, ledgerJournalTrans_FundsTransfer.FundsTransferRefNum);

    ReplyDelete
    Replies
    1. Hi,
      You should use this code at every method from which the journal/document is getting deleted. For eg.: LedgerJournalTrans-> deleteVoucher in my case because i was generating the numberSeq at journal line.

      Delete
    2. Thanks for reply,
      How to recognize whether NumberSeq number have been used or not

      Delete
    3. If we are writing the code on deletion that means records was created at the first place that's the reason we need to delete the record and free the NumSeq.

      Delete