# Freeze Order

Freeze the order's fulfillment in the order management system.

```nolang
POST /v2/cpq/carts/{order_ID}/prevalidate
```

Before canceling an order, call the order management system and return the real-time point of no return (PONR) status to confirm that the order can be canceled.

With CME Winter '20 and later releases, clicking the **Cancel** button calls the CPQ/CancelOrder OmniScript, which calls the preValidate and createSupplementalOrder methods.

Prior to CME Winter '20, the **Cancel Order** button was displayed and it would call the submitCancelOrder method. For backward compatibility, you can adjust the value of the [CPQ Configuration Settings Reference](https://help.salesforce.com/s/articleView?id=ind.comms_t_cpq_configuration_settings_reference\_148927.htm) configuration setting.

The preValidate method freezes the order's fulfillment in the order management system, which can respond with one of the following:

- Accepted: The fulfillment is (or can be eventually) frozen. When the order management system accepts the freeze order request, Odin will set the Order.OrderStatus\_\_c to the Frozen state.

- Rejected: The fulfillment cannot be Frozen. Odin looks for the reasonCode field. If the reasonCode value is PONR, Odin sets the Changes Allowed flag in the Order and OrderItem to false.

## Remote Method

```nolang
preValidate
```

## REST Handler

```nolang
APIPrevalidateCartsCPQV2
```

## Apex

```nolang
public static void preValidate(Id orderId)
{
  vlocity_cmt.CpqAppHandler handler = new vlocity_cmt.CpqAppHandler();

  /** Setup Input and Output maps **/
  Map<String, Object> inputMap = new Map<String, Object>
  {
      'cartId' => orderId
  };
  Map<String, Object> outputMap = new Map<String, Object>();
  Map<String, Object> optionsMap = new Map<String, Object>();

  handler.invokeMethod('preValidate', inputMap, outputMap, optionsMap);
}
```

## Package

Communication (vlocity_cmt)

## API Parameters and Response Format

For API parameter names and descriptions, see [Cart-Based API Swagger Reference](https://developer.salesforce.com/docs/industries/cme/references/cpq?meta=Summary).

## Resource Information

| Response Format | JSON                                                                 |
| --------------- | -------------------------------------------------------------------- |
| Resource URL    | `/services/apexrest/{namespace}/v2/cpq/carts/{order_ID}/prevalidate` |
| Request Body    | `{"cartId": "order_ID"}`                                             |

## Message Codes

| Code        | Description                                                                                                                                                                                                                                                                                                                                                 |
| ----------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| FREEZE-1026 | The preValidate API can make a Freeze Order request to the Order Management System (OM). This code indicates that OM accepted the Freeze Order request.                                                                                                                                                                                                     |
| FREEZE-1027 | The preValidate API can make a Freeze Order request to the Order Management System (OM). This code indicates that OM rejected the Freeze Order request.                                                                                                                                                                                                     |
| FREEZE-1028 | The preValidate API can make a Freeze Order request to the Order Management System (OM). This code indicates that parameters required by OdinAPIHandler (orderIdList) were not passed. To avoid this, use standard provided implementations for OdinAPIHandler interface.                                                                                   |
| FREEZE-1029 | The preValidate API can make a Freeze Order request to the Order Management System (OM). If OM returns an unrecognized response, then this code is returned by preValidate API. Only Accepted and Rejected are recognized responses for Freeze Order request.                                                                                               |
| FREEZE-1030 | The preValidate API can make a Freeze Order request to the Order Management System (OM). If the OM rejects the request, it can send the reasonCode field to specify why the request was rejected. Recognized reasonCode values include `PONR`, `UNKNOWN`, and `EXCEPTION`. If OM returns any other reasonCode, the preValidate API returns this error code. |
| INVOKE-500  | The preValidate API was called with an incorrect cart ID.                                                                                                                                                                                                                                                                                                   |

**See Also**

- [In-Flight Order Cancellation](https://help.salesforce.com/s/articleView?id=ind.comms_in_flight_order_cancellation.htm)
- [Unfreeze Order](/docs/industries/cme/guide/comms-unfreeze-order.md)
