Cancel Invoices
cancelInvoices API is used to to cancel a set of invoices. It accepts a set of invoice IDs, validates each invoice in the set, cancels the eligible invoices, and returns a list of results (InvoiceActionResult), which includes details for each invoice.
| API | Signature |
|---|---|
| cancelInvoices | static List cancelInvoices(Set invoiceIds, Boolean updateSourceInvStatus, Boolean isSplitInvoice) |
- Validates the invoices and cancels the eligible invoices.
- After cancellation, all billing schedules and usage schedules are set to Pending Billing.
- Only Invoice(s) with a status of Draft, Draft Obsolete, Pending Approved or Approved can be Canceled.
Request Parameters
| Field | Type | Required | Description |
|---|---|---|---|
| invoiceIds | Set | Yes | A set of Invoice record IDs you want to cancel. |
| updateSourceInvStatus | Boolean | Yes | This flag determines whether the source invoice status should be updated as part of the cancellation process. For example, if set to true, the API will update the status of the original invoice record (e.g., from Approved to Cancelled). If false, it may skip this update. |
| isSplitInvoice | Boolean | Yes | Flag to determine if the invoice is a split invoice. |
Response
| Field | Type | Description |
|---|---|---|
| CustomClass.InvoiceActionResult | List | A result parameter is returned for each request parameter. |
Code Sample - Request
Set<Id> invoiceIds = new Set<Id>{'a5TDc00000161lM','a5TDc00000161lN', 'a5TDc00000161lO', 'a5TDc00000161lP', 'a5TDc00000161lQ', 'a5TDc00000161lR', 'a5TDc00000161lG'};
List<Apttus_Billing.CustomClass.InvoiceActionResult> cancelInvoices =
Apttus_Billing.InvoiceService.cancelInvoices(invoiceIds, true, true);
System.debug('-cancelInvoices-'+cancelInvoices);
Code Sample - Response
cancelInvoices-(InvoiceActionResult:[invoiceId=a5TDc00000161mlMAA, isSuccess=true, message=Invoice has been Cancelled.], InvoiceActionResult:[invoiceId=a5TDc00000161mmMAA, isSuccess=true, message=Invoice has been Cancelled.], InvoiceActionResult:[invoiceId=a5TDc00000161mnMAA, isSuccess=true, message=Invoice has been Cancelled.], InvoiceActionResult:[invoiceId=a5TDc00000161moMAA, isSuccess=true, message=Invoice has been Cancelled.])