How to archive and purge transactions programmatically?

SOLVED

Hi all,

I have check on the documentation. but there is no guide to do archive and purge transactions programmatically. What I want to do is to select specific transactions by item code, and archive & purge these transaction, and delete the item code.

thank you

  • +1
    verified answer

    Assuming you're talking about stock transactions, use the Sage.Accounting.Stock.ArchiveStockHistoryCoordinator (and  ArchiveTraceableStockItemsCoordinator if traceable). Set ArchiveType to SIngleStockItem, set the stock item and DateTo then run Archive or ArchiveAsync.

    And there are StockPurgeEntriesCoordinator and StockPurgeTraceableEntriesCoordinator, but these don't allow single stock items.

    However, you won't be able to delete the stock item if it's ever been used in SOP or POP (amongst other things). What I've done before is find all completed SOP/POP standard item lines for the item and convert them to free text lines. Of course if there are any incomplete lines, the item can't be deleted.

  • 0 in reply to Geoff Turner

    Hi Geoff, thank you for the suggestion.

    Based on that, I will try to convert the item lines in SOP and POP to free text lines programmatically, and then do the stock item archived.