Skip to content
Developerhome
Sage Distribution and Manufacturing Operations

Link the record to the attachment

  Less than to read

A mutation can link the _id value returned by the first step to a record.

This is done by adding a record to the _attachment collection that exists on every node able to support attachments.

The following table shows an example of a query for an attachment done on the salesOrder node in the xtremSales package. Some of the fields displayed are not mandatory and others have been omitted.

mutation ($OrderNumber:Id,$AttachmentLink:IntReference) { 
    xtremSales { 
        salesOrder { 
            update 
                (data: {
                    _id: $OrderNumber, 
                    _attachments: [
                        {
                            _action: "create", 
                            _id: "-1", 
                            attachment: $AttachmentLink, 
                            title: "Example"
                        }
                    ]
                }) 
            { 
                _id 
            } 
        } 
    } 
}

In the previous example, the first parameter would be either:

  • the _id
  • the sales order’s natural key preceded by an #

The second parameter would be a string with the _id: 12345 format, where 12345 is the _id value of the attachment.