Update sales orders in bulk

distru-bulk-update-sales-ordersWriteLeafLinkMetrcPOSQuickBooks

Applies 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.

FieldTypeRequiredDescription
idsstring[]YesSales 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).
customerIdstringNoCustomer company. Send billingLocationId and shippingLocationId with it (null allowed): they must be the new customer's locations. Resolve via distru-search-companies.
billingLocationIdstring or nullNoBilling location. Resolve via distru-get-company (includeLocations) on the order's customer. Send null to clear it.
shippingLocationIdstring or nullNoShipping location. Resolve via distru-get-company (includeLocations) on the order's customer. Send null to clear it.
ownerIdstring or nullNoSales rep. Resolve via distru-search-users. Send null to clear it.
internalNotesstring or nullNoNot shown to the customer. Send null to clear it.
externalNotesstring or nullNoShown on the order slip and invoice. Send null to clear it.
statusenum
PENDINGPROCESSINGREADY_TO_SHIPDELIVERINGDELIVEREDCOMPLETEDCANCELED
NoCANCELED releases the order's stock, deletes its pending assemblies and Metrc transfer template, and voids its invoices.
customFieldsobject[]NoOnly the fields listed change. Required custom fields must be set, on update too, while still blank.
customFields[].customFieldIdstringYesResolve via distru-search-custom-fields (entityType SALES_ORDER).
customFields[].valuestring or string[]YesTEXT: 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.

FieldTypePresence
salesOrdersobject[]Always
salesOrders[].idstringAlways
salesOrders[].statusenum
FAILEDUPDATED
Always
salesOrders[].messagestringCan 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.