global with sharing class DiscardPxService
This service class provides functionality for discarding documents. Note that only journals, sales credit notes, sales invoices and payable invoices are currently supported.
global static void discardSync(Set<ID> sourceIDs, String discardReason)
This service enables you to discard documents synchronously.
Depending on the type of document that you are discarding, you must have the appropriate custom permission assigned:
JournalDiscard (Discard Journals) to discard journals
SalesCreditNoteDiscard (Discard Sales Credit Notes) to discard sales credit notes
SalesInvoiceDiscard (Discard Sales Invoices) to discard sales invoices
PayableInvoiceDiscard (Discard Payable Invoices) to discard payable invoices
||Identifies the documents to discard. Note that all the IDs in the set must belong to records of the same object. For example, you cannot mix journals and sales credit notes.
||Reason for discarding the documents.