Skip to content
Developer home
X3

Example GraphQL queries for Sales Orders

  Less than to read

Sales order details for customers in specific countries

{
  sage {
    x3Sales {
      salesOrder(filter: "{ soldToCustomer: { defaultAddress: { countryName: { $in: ['France', 'Deutschland'] } } } }") {
        edges {
          node {
            id
            orderDate
            shipmentDate
            soldToCustomer {
              code
              companyName
              shortCompanyName
              defaultAddress {
                address
                description
                isDefault
                city
                countryName
                website
              }
            }
            billToCustomer {
              code
              companyName
              shortCompanyName
              defaultContact
            }
            payByBusinessPartner {
              code
            }
          }
        }
      }
    }
  }
}

Try it on our demo endpoint

Sales orders sorted by order date in ascending order, with order date greater than that specified

{
  sage {
    x3Sales {
      salesOrder(filter: "{orderDate: {$gt: '2017-01-10'}}" , orderBy: "{ orderDate: 1  }") {
        edges {
          node {
            id
            orderDate
            shipmentDate
          }
        }
      }
    }
  }
}

Try it on our demo endpoint

Sales order with one line creation example (not executable on the read-only demo enpoint)

mutation {
  sage {
    x3Sales {
      salesOrder {
        create(data: {id: "GRAPHQLDEMO", salesSite: "UTFR1", soldToCustomer: "UTFR001", currency: "EUR", category: normal, company: "UTFRA", orderDate: "2018-06-15", paymentTerm: "FRTAC60", taxRule: "FRA", lines: [{lineNumber: 1000, grossPrice: "22.0", product: "UT_KEYBOARD", salesUnit: "UN", quantityInSalesUnitOrdered: "1.0"}]}) {
          id
          taxRule {
            code
          }
          paymentTerm {
            code
          }
          salesSite {
            code
          }
          lines {
            edges {
              node {
                lineNumber
                sequenceNumber
                product {
                  code
                }
              }
            }
          }
          category
          soldToCustomer {
            code
          }
        }
      }
    }
  }
}

Sales order with two lines creation example (not executable on the read-only demo enpoint)

mutation {
  sage {
    x3Sales {
      salesOrder {
        create(data: {id: "GRAPHQLDEMO", salesSite: "UTFR1", soldToCustomer: "UTFR001", currency: "EUR", category: normal, company: "UTFRA", orderDate: "2018-06-15", paymentTerm: "FRTAC60", taxRule: "FRA", lines: [{lineNumber: 1000, grossPrice: "22.0", product: "UT_KEYBOARD", salesUnit: "UN", quantityInSalesUnitOrdered: "1.0"}, {lineNumber: 2000, grossPrice: "520.0", product: "IPHONE", salesUnit: "UN", quantityInSalesUnitOrdered: "1.0"}]}) {
          id
          taxRule {
            code
          }
          paymentTerm {
            code
          }
          salesSite {
            code
          }
          lines {
            edges {
              node {
                lineNumber
                sequenceNumber
                product {
                  code
                }
              }
            }
          }
          category
          soldToCustomer {
            code
          }
        }
      }
    }
  }
}