How to add an attachment to an order

Instructions on adding attachments to orders using GraphQL, including setting specific document types and handling file size limitations.

You can add an attachment to an order by runnning the AddAttachment processing on the Order table.

The following query adds an attachment to an existing order:

mutation upload_invoice_attachment(
        $cid: Int!,
        $orderNo: Int!,
        $fileName: String!,
        $description: String!,
        $data: String!)
{
  useCompany(no: $cid) {
    order_processings {
      addAttachment(
        filter: { orderNo: { _eq: $orderNo } },
        args: { 
           description: $description, 
           fileName: $fileName, 
           fileBytes: $data,
           sendWithInvoicesAndCreditNotes : 1
        }
      )
      {
        succeeded
      }
    }
  }
}
Note

The content of the attachment must be provided as a base64 encoded string.

The precence of the sendWithInvoicesAndCreditNotes : 1 argument will set the order attachment processing to Invoices/credit notes. You can see this in the front-end, when you look at the Order attachment processing column of the Order attachment table.

Order attachment processing

If you want to set any of the other available values, such as Pick lists or Packing slips, then you must use the sendWithDocumentTypes parameter instead. The following table shows the available values for this parameter:

ValueDescription
1Invoices/credit notes
2Consignment notes
4Packing slips
8Pick lists
16Order confirmations
32Quotations
64Purchase orders
128Inquiries
256Production orders
512Order prints
1024Approval requests

The following example shows how to set the sendWithDocumentTypes parameter to Packing slips:

mutation upload_packing_slip_attachment(
        $cid: Int!,
        $orderNo: Int!,
        $fileName: String!,
        $description: String!,
        $data: String!)
{
  useCompany(no: $cid) {
    order_processings {
      addAttachment(
        filter: { orderNo: { _eq: $orderNo } },
        args: { 
           description: $description, 
           fileName: $fileName, 
           fileBytes: $data,
           sendWithDocumentTypes : 4
        }
      )
      {
        succeeded
      }
    }
  }
}
Note

Beware there is a limit to the raw size of a request. Currently, this is set at 15MB. This limit may be prone to future changes.

Last modified September 24, 2024