# Class Status

- [TopLevel.Object](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md)
  - [dw.system.Status](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.system.Status.md)

A Status is used for communicating an API status code back to a client. A status
consists of multiple StatusItem. Most often a Status contains only one StatusItem.
For convenience, a message with parameters is formatted using standard
formatting patterns. If you want to display locale-specific messages in your
application, you should use the Status.getCode() as key for a resource bundle.

## Property Summary

| Property                                                                                                               | Description                                                                                                                                   |
| ---------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------- |
| [ERROR](#error): [Number](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Number.md)                    | status value to indicate an ERROR status                                                                                                      |
| [OK](#ok): [Number](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Number.md)                          | status value to indicate an OK status                                                                                                         |
| [code](#code): [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md) `(read-only)`        | Returns the status code either of the first ERROR StatusItem or when there  is no ERROR StatusITEM, the first StatusItem in the overall list. |
| [details](#details): [Map](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.util.Map.md) `(read-only)`         | Returns the details either of the first ERROR StatusItem or when there  is no ERROR StatusItem, the first StatusItem in the overall list.     |
| [error](#error): [Boolean](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Boolean.md) `(read-only)`    | Checks if the status is an ERROR.                                                                                                             |
| [items](#items): [List](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.util.List.md) `(read-only)`           | Returns all status items.                                                                                                                     |
| [message](#message): [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md) `(read-only)`  | Returns the message either of the first ERROR StatusItem or when there  is no ERROR StatusItem, the first StatusItem in the overall list.     |
| [parameters](#parameters): [List](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.util.List.md) `(read-only)` | Returns the parameters either of the first ERROR StatusItem or when there  is no ERROR StatusItem, the first StatusItem in the overall list.  |
| [status](#status): [Number](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Number.md) `(read-only)`    | Returns the overall status.                                                                                                                   |

## Constructor Summary

| Constructor                                                                                                                                                                                                                                                                                                                                                                                     | Description                                  |
| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------- |
| [Status](#status)()                                                                                                                                                                                                                                                                                                                                                                             | Creates a Status object with no StatusItems. |
| [Status](#statusnumber)([Number](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Number.md))                                                                                                                                                                                                                                                                                     | Creates a Status with a single StatusItem.   |
| [Status](#statusnumber-string)([Number](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Number.md), [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md))                                                                                                                                                                                          | Creates a Status with a single StatusItem.   |
| [Status](#statusnumber-string-string-object)([Number](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Number.md), [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md), [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md), [Object...](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md)) | Creates a Status with a single StatusItem.   |

## Method Summary

| Method                                                                                                                                                                                                                                                                                | Description                                                                                                                                                |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [addDetail](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.system.Status.md#adddetailstring-object)([String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md), [Object](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md)) | Add detail information for the given key of the first ERROR StatusItem  or when there is no ERROR StatusItem, the first StatusItem in the overall list.    |
| [addItem](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.system.Status.md#additemstatusitem)([StatusItem](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.system.StatusItem.md))                                                                                   | Adds an additional status item to this status instance.                                                                                                    |
| [getCode](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.system.Status.md#getcode)()                                                                                                                                                                                        | Returns the status code either of the first ERROR StatusItem or when there  is no ERROR StatusITEM, the first StatusItem in the overall list.              |
| [getDetail](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.system.Status.md#getdetailstring)([String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md))                                                                                            | Returns the detail value for the given key of the first ERROR StatusItem  or when there is no ERROR StatusItem, the first StatusItem in the  overall list. |
| [getDetails](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.system.Status.md#getdetails)()                                                                                                                                                                                  | Returns the details either of the first ERROR StatusItem or when there  is no ERROR StatusItem, the first StatusItem in the overall list.                  |
| [getItems](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.system.Status.md#getitems)()                                                                                                                                                                                      | Returns all status items.                                                                                                                                  |
| [getMessage](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.system.Status.md#getmessage)()                                                                                                                                                                                  | Returns the message either of the first ERROR StatusItem or when there  is no ERROR StatusItem, the first StatusItem in the overall list.                  |
| [getParameters](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.system.Status.md#getparameters)()                                                                                                                                                                            | Returns the parameters either of the first ERROR StatusItem or when there  is no ERROR StatusItem, the first StatusItem in the overall list.               |
| [getStatus](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.system.Status.md#getstatus)()                                                                                                                                                                                    | Returns the overall status.                                                                                                                                |
| [isError](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.system.Status.md#iserror)()                                                                                                                                                                                        | Checks if the status is an ERROR.                                                                                                                          |

### Methods inherited from class Object

[assign](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#assignobject-object), [create](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#createobject), [create](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#createobject-object), [defineProperties](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#definepropertiesobject-object), [defineProperty](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#definepropertyobject-object-object), [entries](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#entriesobject), [freeze](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#freezeobject), [fromEntries](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#fromentriesiterable), [getOwnPropertyDescriptor](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#getownpropertydescriptorobject-object), [getOwnPropertyNames](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#getownpropertynamesobject), [getOwnPropertySymbols](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#getownpropertysymbolsobject), [getPrototypeOf](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#getprototypeofobject), [hasOwnProperty](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#hasownpropertystring), [is](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#isobject-object), [isExtensible](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#isextensibleobject), [isFrozen](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#isfrozenobject), [isPrototypeOf](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#isprototypeofobject), [isSealed](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#issealedobject), [keys](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#keysobject), [preventExtensions](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#preventextensionsobject), [propertyIsEnumerable](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#propertyisenumerablestring), [seal](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#sealobject), [setPrototypeOf](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#setprototypeofobject-object), [toLocaleString](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#tolocalestring), [toString](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#tostring), [valueOf](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#valueof), [values](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#valuesobject)

## Property Details

### ERROR

- ERROR: [Number](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Number.md)
  - : status value to indicate an ERROR status

***

### OK

- OK: [Number](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Number.md)
  - : status value to indicate an OK status

***

### code

- code: [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md) `(read-only)`
  - : Returns the status code either of the first ERROR StatusItem or when there
    is no ERROR StatusITEM, the first StatusItem in the overall list.

    The status code is the unique identifier for the message and can be used by
    client programs to check for a specific status and to generate a localized
    message.

***

### details

- details: [Map](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.util.Map.md) `(read-only)`
  - : Returns the details either of the first ERROR StatusItem or when there
    is no ERROR StatusItem, the first StatusItem in the overall list.

***

### error

- error: [Boolean](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Boolean.md) `(read-only)`
  - : Checks if the status is an ERROR. The Status is an ERROR if one of the
    contained StatusItems is an ERROR.

***

### items

- items: [List](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.util.List.md) `(read-only)`
  - : Returns all status items.

***

### message

- message: [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md) `(read-only)`
  - : Returns the message either of the first ERROR StatusItem or when there
    is no ERROR StatusItem, the first StatusItem in the overall list.

    Note: Custom code and client programs must not use this message to identify
    a specific status. The getCode() must be used for that purpose. The actual
    message can change from release to release.

***

### parameters

- parameters: [List](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.util.List.md) `(read-only)`
  - : Returns the parameters either of the first ERROR StatusItem or when there
    is no ERROR StatusItem, the first StatusItem in the overall list.

***

### status

- status: [Number](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Number.md) `(read-only)`
  - : Returns the overall status. If all StatusItems are OK, the method returns
    OK. If one StatusItem is an ERROR it returns ERROR.

***

## Constructor Details

### Status()

- Status()
  - : Creates a Status object with no StatusItems.

***

### Status(Number)

- Status(status: [Number](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Number.md))
  - : Creates a Status with a single StatusItem. The status is set to the given
    value.

    **Parameters:**

    - status - either OK or ERROR

***

### Status(Number, String)

- Status(status: [Number](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Number.md), code: [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md))
  - : Creates a Status with a single StatusItem. The StatusItem is initialized
    with the given values.

    **Parameters:**

    - status - either OK or ERROR
    - code - a string representing a more detailed status code, e.g. "IMPEX-120"

***

### Status(Number, String, String, Object...)

- Status(status: [Number](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Number.md), code: [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md), message: [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md), parameters: [Object...](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md))
  - : Creates a Status with a single StatusItem. The StatusItem is initialized
    with the given values.

    **Parameters:**

    - status - either OK or ERROR
    - code - a string representing a more detailed status code, e.g. "IMPEX-120".
    - message - a default human readable message
    - parameters - a list of parameters to construct a custom message

***

## Method Details

### addDetail(String, Object)

- addDetail(key: [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md), value: [Object](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md)): void
  - : Add detail information for the given key of the first ERROR StatusItem
    or when there is no ERROR StatusItem, the first StatusItem in the overall list.

    **Parameters:**

    - key - the key of the first ERROR StatusItem or the first StatusItem  in the list.
    - value - the detail value.

***

### addItem(StatusItem)

- addItem(item: [StatusItem](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.system.StatusItem.md)): void
  - : Adds an additional status item to this status instance.

    **Parameters:**

    - item - the status item to add.

***

### getCode()

- getCode(): [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md)
  - : Returns the status code either of the first ERROR StatusItem or when there
    is no ERROR StatusITEM, the first StatusItem in the overall list.

    The status code is the unique identifier for the message and can be used by
    client programs to check for a specific status and to generate a localized
    message.

    **Returns:**

    - the status code

***

### getDetail(String)

- getDetail(key: [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md)): [Object](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md)
  - : Returns the detail value for the given key of the first ERROR StatusItem
    or when there is no ERROR StatusItem, the first StatusItem in the
    overall list.

    **Parameters:**

    - key - the key for the detail to return.

    **Returns:**

    - the detail value for the given key of the first ERROR StatusItem
      or when there is no ERROR StatusItem, the first StatusItem in the
      overall list.

***

### getDetails()

- getDetails(): [Map](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.util.Map.md)
  - : Returns the details either of the first ERROR StatusItem or when there
    is no ERROR StatusItem, the first StatusItem in the overall list.

    **Returns:**

    - the details either of the first ERROR StatusItem or when there
      is no ERROR StatusItem, the first StatusItem in the overall list.

***

### getItems()

- getItems(): [List](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.util.List.md)
  - : Returns all status items.

    **Returns:**

    - all status items.

***

### getMessage()

- getMessage(): [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md)
  - : Returns the message either of the first ERROR StatusItem or when there
    is no ERROR StatusItem, the first StatusItem in the overall list.

    Note: Custom code and client programs must not use this message to identify
    a specific status. The getCode() must be used for that purpose. The actual
    message can change from release to release.

    **Returns:**

    - the message either of the first ERROR StatusItem or when there
      is no ERROR StatusItem, the first StatusItem in the overall list.

***

### getParameters()

- getParameters(): [List](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.util.List.md)
  - : Returns the parameters either of the first ERROR StatusItem or when there
    is no ERROR StatusItem, the first StatusItem in the overall list.

    **Returns:**

    - the parameters either of the first ERROR StatusItem or when there
      is no ERROR StatusItem, the first StatusItem in the overall list.

***

### getStatus()

- getStatus(): [Number](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Number.md)
  - : Returns the overall status. If all StatusItems are OK, the method returns
    OK. If one StatusItem is an ERROR it returns ERROR.

    **Returns:**

    - either OK or ERROR

***

### isError()

- isError(): [Boolean](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Boolean.md)
  - : Checks if the status is an ERROR. The Status is an ERROR if one of the
    contained StatusItems is an ERROR.

    **Returns:**

    - true if status is an ERROR, false otherwise.

***
