Cancels a document, typically reverting it to a draft or canceled state.

This function performs an asynchronous request to the server to cancel a document of the specified type. Cancelling a document usually means it will be marked as "canceled" or moved to a state where no further processing can be done, effectively halting any ongoing workflows or actions related to the document.

// Cancel an 'Employee' document by its identifier.
const cancelParams: cancelParams = {
doctype: 'Employee',
name: 'EMP-001',
};
const canceledEmployee = await cancelDoc(cancelParams);
console.log(canceledEmployee); // Logs the canceled 'Employee' document, showing updated state
// Cancel a 'Product' document with a specific name.
const cancelParams: cancelParams = {
doctype: 'Product',
name: 'PRD-123',
};
const canceledProduct = await cancelDoc(cancelParams);
console.log(canceledProduct); // Logs the canceled 'Product' document, showing updated state
// Cancel an 'Order' document by its identifier.
const cancelParams: cancelParams = {
doctype: 'Order',
name: 'ORD-456',
};
const canceledOrder = await cancelDoc(cancelParams);
console.log(canceledOrder); // Logs the canceled 'Order' document, showing updated state

Throws an error if the request fails or if there is an issue with cancelling the document.

  • Type Parameters

    Parameters

    • params: cancelParams

      The parameters for cancelling the document. This includes:

      • doctype: The document type of the document to be canceled.
      • name: The name or identifier of the document to be canceled.

    Returns Promise<T>

    A promise that resolves to the canceled document of type T. The returned document includes the data as updated to reflect its cancelled state.