Update sales orders in bulk
distru-bulk-update-sales-ordersWriteLeafLinkMetrcPOSQuickBooksApplies the same header changes to many sales orders, saving each one on its own as the sales order form does. Each save pushes the change to LeafLink for an order that came from it, to your POS (Dutchie, Blaze or Treez) when it syncs there, and to QuickBooks for the invoices a cancel voids. Invoices, shipments, line prices and charge and tax amounts are left as they are. On an order with a Metrc transfer template, a save with every line fulfilled updates the template in Metrc, and canceling the order deletes it.
Inputs
Every tool also takes the common inputs.
| Field | Type | Required | Description |
|---|---|---|---|
| ids | string[] | Yes | Sales orders to change. Resolve via distru-search-sales-orders. Split a larger set into several calls; if you can make only one, say which sales orders are left (or how many, if the list is long). |
| customerId | string | No | Customer company. Send billingLocationId and shippingLocationId with it (null allowed): they must be the new customer's locations. Resolve via distru-search-companies. |
| billingLocationId | string or null | No | Billing location. Resolve via distru-get-company (includeLocations) on the order's customer. Send null to clear it. |
| shippingLocationId | string or null | No | Shipping location. Resolve via distru-get-company (includeLocations) on the order's customer. Send null to clear it. |
| ownerId | string or null | No | Sales rep. Resolve via distru-search-users. Send null to clear it. |
| internalNotes | string or null | No | Not shown to the customer. Send null to clear it. |
| externalNotes | string or null | No | Shown on the order slip and invoice. Send null to clear it. |
| status | enumPENDINGPROCESSINGREADY_TO_SHIPDELIVERINGDELIVEREDCOMPLETEDCANCELED | No | CANCELED releases the order's stock, deletes its pending assemblies and Metrc transfer template, and voids its invoices. |
| customFields | object[] | No | Only the fields listed change. Required custom fields must be set, on update too, while still blank. |
| customFields[]. | string | Yes | Resolve via distru-search-custom-fields (entityType SALES_ORDER). |
| customFields[]. | string or string[] | Yes | TEXT: the text. NUMBER: a plain decimal, such as "12.5". USER: the user's id (usr_…). DROPDOWN: the option name. CHECKBOX: an array of option names. DATE: YYYY-MM-DD, company timezone. "" or [] clears the field. |
Output
Presence on a nested field assumes its parent exists.
| Field | Type | Presence |
|---|---|---|
| salesOrders | object[] | Always |
| salesOrders[]. | string | Always |
| salesOrders[]. | enumFAILEDUPDATED | Always |
| salesOrders[]. | string | Can be null |
What the AI reads
Applies the same header changes to up to 12 sales orders, saving each on its own as a distru-mutate-sales-order UPDATE does, with the same rules and side effects (LeafLink, POS, QuickBooks, Metrc), except that an order missing a required custom field still saves, price tiers are not applied again (line prices stay, even for a new customer), charges and taxes keep their amounts, and invoices and shipments are not updated (CANCELED still voids invoices); returns one result per order, in the order given (a repeated id once), with the reason in message. UPDATED also when it already had the values. FAILED: you can't edit the order, it was deleted during the call, or its save was refused; the others still save. A location that isn't the order's customer's fails only that order. Refused whole for an unknown id, a malformed value, a customer that doesn't exist, a location that is neither your company's nor a customer's, an owner you can't assign, a customer your team can't see, or a new customer for orders placed on your menu by different buyers; permission denied when you can't edit sales orders or your team can't see an order. Lines and charges: distru-mutate-sales-order. Read the new values with distru-get-sales-order. Sparse update: only the fields passed change, on every order; a field sent as null is cleared on all of them.