Update sales order

Hi

We are in the process of setting up a connection between Microsoft Business Central and our logistical partner that usage ShipHero.

In this case the sales orders are created in Business Central and we send the sales orders to Shiphero. This work without any issue. Although in some cases the sales orders are being updated in Business Central and those changes need to be updated in Shiphero as well.

We run into the issue here that updating the sales order lines isn’t allowed via the GraphAPI. What would be the correct way to update the sales order lines?

Thanks in advance!
RJ

Hey @RWA,

Thanks for reaching out!

Would you mind sharing the request_id or returned in the update mutations you’re running, so I could take a look?
If you’re only able to provide the mutation, that works too!

Please let me know if you have any questions or concerns.

Best,
RayanP

Hi @sh-agent,

Thanks for the reply, I asked our developer to provide the requested information:

With request 652400cdb71c743d80cd7cbe the update function is working because we diddn’t specify the “line_items” object. If we specify this object to update the line. The call fails because we cannot use the line_items: {} object.

The request:

{ “query”: “mutation { order_update( data: { order_id: "T3JkZXI6Mzk4NzYwMjkw" shipping_address: { first_name: "Adatum Corporation" company: "Adatum Corporation" address1: "Station Road, 21" city: "Arnhem" zip: "1705 RE" country: "NL" email: "loek.walravens@contoso.nl" phone: "" } billing_address: { first_name: "Adatum Corporation" company: "Adatum Corporation" address1: "Station Road, 21" city: "Arnhem" zip: "1705 RE" country: "NL" email: "loek.walravens@contoso.nl" phone: "" } line_items: [{ sku: "109AP300018_S" partner_line_item_id: "101012-10000" quantity: 1 price: "1.00" product_name: "TEST" warehouse_id: "V2FyZWhvdXNlOjgzNDUz=" },{ sku: "109AP300018_S" partner_line_item_id: "101012-20000" quantity: 1 price: "1.00" product_name: "TEST" warehouse_id: "V2FyZWhvdXNlOjgzNDUz=" },{ sku: "109AP300018_S" partner_line_item_id: "101012-30000" quantity: 1 price: "1.00" product_name: "TEST" warehouse_id: "V2FyZWhvdXNlOjgzNDUz=" }] required_ship_date: "11-10-23" } ) { request_id complexity order { id order_number line_items(first: 1) { edges { node { id } } } } }}” }

The response:

{“errors”:[{“message”:“Argument "data" has invalid value {order_id: "T3JkZXI6Mzk4NzYwMjkw", shipping_address: {first_name: "Adatum Corporation", company: "Adatum Corporation", address1: "Station Road, 21", city: "Arnhem", zip: "1705 RE", country: "NL", email: "loek.walravens@contoso.nl", phone: ""}, billing_address: {first_name: "Adatum Corporation", company: "Adatum Corporation", address1: "Station Road, 21", city: "Arnhem", zip: "1705 RE", country: "NL", email: "loek.walravens@contoso.nl", phone: ""}, line_items: [{sku: "109AP300018_S", partner_line_item_id: "101012-10000", quantity: 1, price: "1.00", product_name: "TEST", warehouse_id: "V2FyZWhvdXNlOjgzNDUz="}, {sku: "109AP300018_S", partner_line_item_id: "101012-20000", quantity: 1, price: "1.00", product_name: "TEST", warehouse_id: "V2FyZWhvdXNlOjgzNDUz="}, {sku: "109AP300018_S", partner_line_item_id: "101012-30000", quantity: 1, price: "1.00", product_name: "TEST", warehouse_id: "V2FyZWhvdXNlOjgzNDUz="}], required_ship_date: "11-10-23"}.\nIn field "line_items": Unknown field.”,“locations”:[{“line”:1,“column”:32}]}]}

Yours,
RJ

1 Like

Hey @RWA,

Thanks for hanging in there!

To update the line_items for an order, you should try calling order_update_line_items mutation. Below is an example of the query:

mutation {
  order_update_line_items(
    data: {
      order_id: "string"
      line_items: [
        {
          id: "string"
          partner_line_item_id: "string"
          quantity: 0
          price: "string"
        }
      ]
    }
  ) {
    request_id
    complexity
    order {
      id
      legacy_id
      order_number
      line_items(first: 5) {
        edges {
          node {
            id
            legacy_id
            sku
            quantity
          }
        }
      }
    }
  }
}

I also noticed that in the above request the line_item data is sent three times for the same SKU with no changes. There only needs to be one entry per line_item.

Please let me know if you have any questions or concerns!

Best,
RayanP

Hi Rayan,

Thanks for the reply! our developer will work on it next tuesday.
Will report back if any issues come up.

Yours,
RJ

1 Like