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 invoices| HTTP | Operation | Type | Object | DTO Why-DTOs? |
|---|---|---|---|---|
| (Mutation Why 200?) | linkRelatedSalesDocument |
LinkRelatedSalesDocumentGLDtoInput |
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: LinkRelatedSalesDocumentGLDtoInput!) {
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.