---
schema_version: "1"
id: 6dfea04faeb9149b502bfffd0ff817b06ae192ca24105dc83d056cdd78577bb4
title: unionItems
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/dataweave/2.4/dw-types-functions-unionitems.md
canonical_url: https://docs.mulesoft.com/dataweave/2.4/dw-types-functions-unionitems
source_site: docs.mulesoft.com
content_type: documentation
content_hash: e9e3dc825cacfc96fb11b3b53f9f2fd848094af726160154294b5b589cc61b01
description: MuleSoft Documentation Site
release: "2.4"
latest: false
---
---
product: DataWeave
version: 2.4
---

# unionItems

> For the full documentation index, see: https://docs.mulesoft.com/llms.txt

## unionItems(t: Type): Array<Type>

Returns an array of all the types that define a given Union type. This function fails if the input
is not a Union type.

_Introduced in DataWeave version 2.3.0._

### Parameters

<table><colgroup><col> <col></colgroup><thead><tr><th>Name</th><th>Description</th></tr></thead><tbody><tr><td><p><code>t</code></p></td><td><p>The type to check.</p></td></tr></tbody></table>

### Example

This example shows how `unionItems` behaves with different inputs.

#### Source

```DataWeave
%dw 2.0
import * from dw::core::Types
type AType = String | Number
output application/json
---
{
   a: unionItems(AType)
}
```

#### Output

```Json
{
  "a": ["String","Number"]
}
```
