Submits a document to the server for final processing.

This function performs an asynchronous request to the server to submit a document of the specified type. Submitting a document typically means it is moved to a final state, such as "submitted" or "completed," depending on the document type and the business logic of the application. Once submitted, the document may no longer be editable or may trigger additional workflows.

// Submit an 'Employee' document for final processing.
const employee: BareBoneDoc = {
doctype: 'Employee',
name: 'EMP-001',
employee_name: 'John Doe',
designation: 'Software Engineer',
department: 'Engineering',
};
const submittedEmployee = await submitDoc(employee);
console.log(submittedEmployee); // Logs the submitted 'Employee' document, with updated state or status
// Submit a 'Product' document to mark it as completed.
const product: BareBoneDoc = {
doctype: 'Product',
name: 'PRD-123',
product_name: 'Laptop',
price: 999.99,
stock: 50,
};
const submittedProduct = await submitDoc(product);
console.log(submittedProduct); // Logs the submitted 'Product' document, with updated state or status
// Submit an 'Order' document for final approval or processing.
const order: BareBoneDoc = {
doctype: 'Order',
name: 'ORD-456',
customer_name: 'Alice Smith',
order_date: '2024-09-08',
total_amount: 299.99,
};
const submittedOrder = await submitDoc(order);
console.log(submittedOrder); // Logs the submitted 'Order' document, with updated state or status

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

  • Type Parameters

    Parameters

    • doc: T

      The document to be submitted. The type T should match the schema of the document being submitted.

    Returns Promise<T>

    A promise that resolves to the submitted document of type T. The returned document includes the data as updated or processed by the submission.