The LinkRelatedSalesDocument service allows you to establish a relationship between two existing sales documents, when the transformation is allowed (see the transformation table).
As soon as a sales document is created, an entry is automatically added in RelatedSalesDocument for it.
This action updates the related record by setting the originId with the identifier of the origin document.
LinkRelatedSalesDocument
Quick Links
Accounts Accounting Entries Products Customers Sales quotes Sales invoices Suppliers Purchase invoicesThis feature is currently under development and, although not available in the current version, its preliminary documentation is provided to give you a preview of the enhancements that will be included in an upcoming update.
| HTTP | Operation | Type | Object | DTO Why-DTOs? | 
|---|---|---|---|---|
| For a query, it returns a result already prepared by Sage Active, with no possibility to add filters, sorts, or explore the data further, or it executes an action (e.g., sending an email). For a mutation, it executes a specific business action, also carried out by Sage Active, which will impact the data (e.g., generating a credit note from an invoice). | linkRelatedSalesDocument | LinkRelatedSalesDocumentInput | 
Description
 
Functionality
- Relation Creation: Links a target sales document to its origin sales document.
- Validation: Ensures that only authorized transformations are allowed (e.g. Quote → Order, Quote → Invoice).
Response
The service returns the identifiers of the linked related sales document, along with its updated fields.
How to use the LinkRelatedSalesDocument service?
GraphQL Mutation
mutation($input: LinkRelatedSalesDocumentInput!) {
  linkRelatedSalesDocument(input: $input) {
    documentId
    documentType
    originId
    originDocumentType
  }
}
GraphQL Variables
{
  "input": {
    "documentId": "33333333-aaaa-bbbb-cccc-444444444444",
    "originId": "11111111-aaaa-bbbb-cccc-222222222222"
  }
}
Example Response
{
  "data": {
    "linkRelatedSalesDocument": {
      "documentId": "33333333-aaaa-bbbb-cccc-444444444444",
      "documentType": "ORDER",
      "originId": "11111111-aaaa-bbbb-cccc-222222222222",
      "originDocumentType": "QUOTE",
    }
  }
}
linkRelatedSalesDocument Input parameters
| Fields | Type | Description | 
|---|---|---|
| documentId | UUID | Unique identifier of the sales document to link | 
| originId | UUID | Unique identifier of the origin sales document (the source) | 
linkRelatedSalesDocument Response
| Fields | Type | Description | 
|---|---|---|
| documentId | UUID | Id of the target sales document | 
| documentType | 
 | Type of the target sales document | 
| originId | UUID | Id of the origin sales document | 
| originDocumentType | 
 | Type of the origin sales document | 
Info
- The mutation only succeeds if the transformation between the originDocumentTypeanddocumentTypeis allowed.
- Otherwise, an error is returned.
- The logic is consistent with the allowed transformations table.