> For the complete documentation index, see [llms.txt](https://docs.unimarket.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.unimarket.com/documentation/transactions-orders-receipts-invoices-and-more/cxml-order-integration-change-orders.md).

# cXML Order Integration - Change Orders

In Unimarket, change orders (edits to existing purchase orders) can be handled using two distinct logical configurations. The method chosen determines how integration messages are structured when they are sent to your ERP or supplier systems.

## Comparison Summary

| Feature          | New Order Numbers                    | Order Versions                          |
| ---------------- | ------------------------------------ | --------------------------------------- |
| **PO ID Status** | Changes with every edit              | Remains the same                        |
| **cXML Type**    | `delete` followed by `new`           | `update`                                |
| **Traceability** | Linked via `order-source-identifier` | Linked via `orderID` and `orderVersion` |
| **Best For**     | ERPs that cannot modify existing POs | ERPs that support multi-versioning      |

## Option 1: Using New Order Numbers

In this configuration, every time an order is edited, the system treats the change as a cancellation of the old record and the creation of a completely new one.

### The Integration Sequence

1. **Original Order**: Sent as `type="new"` with a unique ID (e.g., `1004891`).
2. **Order Edit**: Triggered when a user saves changes.
3. **Cancellation Message**: Sent with the original ID (`1004891`) and `type="delete"`.

```xml
<OrderRequest>
    <OrderRequestHeader orderDate="2023-04-06T14:33:37.680+12:00"
                        orderID="1004891"
                        orderType="regular"
                        type="delete">
```

4. **Replacement Message**: Sent with a **new** ID (`1004892`) and `type="new"`.

```xml
<OrderRequest>
    <OrderRequestHeader orderDate="2023-04-06T14:35:19.707+12:00"
                        orderID="1004892"
                        orderType="regular"
                        type="new">
```

### Key Extrinsics for Traceability

To help your ERP link these two separate records, the replacement order contains specific metadata:

* `order-source-type`: Set to `EDIT_ORDER`.
* `order-source-identifier`: Contains the original order number (e.g., `1004891`).

```xml
</Extrinsic>
<Extrinsic name="shippingNote"/>
<Extrinsic name="order-submission">ELECTRONIC</Extrinsic>
<Extrinsic name="requisition-created-date">2023-04-06T14:34:20.000+12:00</Extrinsic>
<Extrinsic name="organization">Unimarket eProcurement</Extrinsic>
<Extrinsic name="organization-unit">Information Technology</Extrinsic>
<Extrinsic name="requisition-justification"/>
<Extrinsic name="is-retrofit-order">no</Extrinsic>
<Extrinsic name="order-source-type">EDIT_ORDER</Extrinsic>
<Extrinsic name="order-source-identifier">1004891</Extrinsic>
<Extrinsic name="requisition-source-type">EDIT_ORDER</Extrinsic>
```

## Option 2: Using Order Versions

In this configuration, the Purchase Order maintains its unique identifier throughout its lifecycle. Changes are tracked via an incrementing version number.

### The Integration Sequence

1. **Original Order**: Sent as `type="new"` with a unique ID (e.g., `100024`).

```xml
<OrderRequest>
    <OrderRequestHeader orderDate="2023-03-09T16:54:51.281+10:00"
                        orderID="100024"
                        orderType="regular"
                        type="new">
```

2. **Order Edit**: Triggered when a user saves changes.
3. **Update Message**: Sent with the **same** ID (`100024`) but the header changes to `type="update"`.

### XML Header Attributes

When an update is sent, the OrderRequestHeader includes:

* `type="update"`: Signals a change to an existing record.
* `orderVersion="2"`: Indicates the revision level (starts at 2 and increases).
* `isInternalVersion="no"`: Confirms this is an external change intended for the supplier/ERP.

```xml
<OrderRequest>
    <OrderRequestHeader isInternalVersion="no"
                        orderDate="2023-03-09T16:55:38.672+10:00"
                        orderID="100024"
                        orderType="regular"
                        orderVersion="2"
                        type="update">
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.unimarket.com/documentation/transactions-orders-receipts-invoices-and-more/cxml-order-integration-change-orders.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
