---
schema_version: "1"
id: 20cfed35c9654939cb8effbf92b71ca15f93e9ae09f08ed66c040db74bf20ec7
title: appendIfMissing
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/dataweave/2.3/dw-strings-functions-appendifmissing.md
canonical_url: https://docs.mulesoft.com/dataweave/2.3/dw-strings-functions-appendifmissing
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 5d83446642b1e1cbb63bf6e6db2bdee8de92e00b23941e4b8d7161c9e702979e
description: MuleSoft Documentation Site
release: "2.3"
latest: false
---
---
product: DataWeave
version: 2.3
---

# appendIfMissing

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

## appendIfMissing(String, String): String

Appends the `suffix` to the end of the `text` if the `text` does not already ends with the `suffix`.

_Introduced in DataWeave 2.2.0. Supported by Mule 4.2 and later._

### Parameters

<table><colgroup><col> <col></colgroup><thead><tr><th>Name</th><th>Description</th></tr></thead><tbody><tr><td><p><code>text</code></p></td><td><p>The input string.</p></td></tr><tr><td><p><code>suffix</code></p></td><td><p>The text used as the suffix.</p></td></tr></tbody></table>

### Example

This example shows how `appendIfMissing` behaves with different inputs and sizes.

#### Source

```DataWeave
%dw 2.0
import appendIfMissing from dw::core::Strings
output application/json
---
{
  "a": appendIfMissing(null, ""),
  "b": appendIfMissing("abc", ""),
  "c": appendIfMissing("", "xyz") ,
  "d": appendIfMissing("abc", "xyz") ,
  "e": appendIfMissing("abcxyz", "xyz")
}
```

#### Output

```JSON
{
  "a": null,
  "b": "abc",
  "c": "xyz",
  "d": "abcxyz",
  "e": "abcxyz"
}
```

## appendIfMissing(Null, String): Null

Helper function that enables `appendIfMissing` to work with a `null` value.
