---
schema_version: "1"
id: a73c699d53e345cf8ba1acd31bf38e7ebf81521237520e97c7cec688aa73e87d
title: appendIfMissing
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/dataweave/latest/dw-strings-functions-appendifmissing.md
canonical_url: https://docs.mulesoft.com/dataweave/latest/dw-strings-functions-appendifmissing
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 23547e963a290a2447676e23721a6ec1128632211e7738107afa9087d614ddc4
description: MuleSoft Documentation Site
release: "2.13"
latest: true
---
---
product: DataWeave
version: 2.13
is-latest-version: true
---

# appendIfMissing

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

## appendIfMissing(text: String, suffix: String): String

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

_Introduced in DataWeave version 2.2.0._

### 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(text: Null, suffix: String): Null

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

_Introduced in DataWeave version 2.2.0._
