---
title: Recipient data
slug: campaign/docs/recipient-data
docTags: 
createdAt: 2026-07-20T15:45:04.128Z
---

This topic describes how you can use field functions to process recipient data and modify texts and time specifications.

:::hint{type="info"}
**Note**

Use your specific data and recipient list fields, and test the field functions before using them in a mailing.
:::

## Formatting dates

For example, if you have a recipient list field for the date of the last purchase, you can use a field function to display the date in the mailing text: *We miss you! You last ordered something on 14.01.2020 and we would be happy to see you again! Enclosed you will find a $10 shopping voucher!*

Since the date is stored in a standard format and would be displayed in the mailing text as *2020-01-14 10:12*:0&#x30;*.0*, for example, you can format the date using the following Velocity code:

```velocity
$DateTimeHelper.formatDate("dd.MM.yyyy", $user.data.date)
```

## Displaying dates from recipient list fields

To display dates from recipient list fields as formatted text, you can use the following Velocity code:

```velocity
#if(!$StringHelper.isEmpty($!user.data.date))$DateTimeHelper.formatDate("dd.MM.yyyy", $user.data.date)#end
```

## Displaying the current date

To display the current date as formatted text, you can use the following Velocity code:

```velocity
$DateTimeHelper.formatDate("dd.MM.yyyy", $DateTimeHelper.getCurrentDate().getTime())
```

## Displaying the current calendar week

To display the current calendar week as formatted text, you can use the following Velocity code:

```velocity
$DateTimeHelper.formatDate("ww", $DateTimeHelper.getCurrentDate().getTime(), $Common.locale("en", "EN", ""))
```

## Displaying periods in years

To output the period in years between the current date and the date in a recipient list field as formatted text, you can use the following Velocity code:

```velocity
#set($date = $user.data.DATE_RECIPIENT_LIST_FIELD_NAME)#if ($StringHelper.isEmpty($date))  #set($date = $DateTimeHelper.getCurrentDate().getTime())#end#set($durationList = $StringHelper.splitToList($DateTimeHelper.getDuration($date), 'd', false, true))#if ($durationList.size() > 1)  #set ($days = $StringHelper.string2int($durationList.get(0), 0))#else  #set ($days = 0)#end#set($years = $days / 365)#if ($years >= 1)  You are our customer for #if ($years == 1)year#else$years years#end!#end
```

:::hint{type="info"}
**Tip**

The Velocity code displays, for example, the following text: *You are our customer for 26 years!*
:::

## Numbers and comparisons

You can use Velocity to compare numbers from recipient list fields.

### Greater than

```velocity
#if($user.data.RECIPIENTLISTFIELD > 10)  OUTPUT#end
```

### Greater or equal

```velocity
#if($user.data.RECIPIENTLISTFIELD >= 10)  OUTPUT#end
```

### Less than

```velocity
#if($user.data.RECIPIENTLISTFIELD < 10)  OUTPUT#end
```

### Less or equal

```velocity
#if($user.data.RECIPIENTLISTFIELD <= 10)  OUTPUT#end
```

### Equal

```velocity
#if($user.data.RECIPIENTLISTFIELD == 10)  OUTPUT#end
```

### Unequal

```velocity
#if($user.data.RECIPIENTLISTFIELD != 10)  OUTPUT#end
```

## Generating random numbers

To generate a random number, for example to load a random image from the file server, you can use the following Velocity code:

```velocity
#set ($random = $MathHelper.random(10))$random
```

:::hint{type="info"}
**Tip**

The Velocity code displays a number between 0 and 10. It can also be a 0.
:::

## Replacing texts

To replace text from recipient list fields (for example HTML code with special characters for the text version), you can add the following ODR code as text content:

```html
<odr:set value="%{user.data.RECIPIENTLISTFIELD}" var="content"/><odr:set value="WHAT" var="what"/><odr:set value="WITH" var="with"/><odr:set value="%{replace(content,what,with)}" var="newtext"/><odr:out value="%{newtext}"/>
```

## Adding blank lines to the text version

To convert HTML breaks (`<br/>`) to blank lines for the text version, you can add the following ODR code as text content:

```html
<odr:set value="%{user.data.RECIPIENTLISTFIELD}" var="content"/><odr:set value="WHAT" var="what"/><odr:set value="%{character('10')}" var="with"/><odr:set value="%{replace(content,what,with)}" var="newtext"/><odr:out value="%{newtext}"/>
```

## Upper or lower case letters

You can use the following Velocity code to display text from recipient list fields as uppercase letters:

```velocity
$user.data.RECIPIENTLISTFIELD.toUpperCase()
```

You can use the following Velocity code to display text from recipient list fields as lowercase letters:

```velocity
$user.data.RECIPIENTLISTFIELD.toLowerCase()
```

## [recipient-data.mdx](docId\:tKNrmCEQWLuLbI5HEBrSS)Generating bar codes

If you use the [coupon system](docId\:V5OJDVRBAoUBDge9djCe6) to generate machine-readable bar codes, you can use Velocity to create bar code field functions based on your recipient list fields.

To create bar code field functions, you need the following information:

- **Recipient list field**. Internal name of the recipient list field you want to use for the bar code.
  - **EAN-13 bar code**. Use the value *ean13barcode*.
  - **Code 128 bar code**. Use one of the following values:
    - Default character set: *code128barcode* (automatically switches between the character sets A, B, and C)
    - Character set A: *code128abarcode*
    - Character set B: *code128bbarcode*
    - Character set C: *code128cbarcode*
  - **Interleaved 2 of 5 bar code**. Use the value *twooffivebarcode*.**Bar code type**. Select one of the following bar code types:
- **Bar code size**. You can specify the bar code size using the *width and height* in pixels or the *line thickness* in pixels (1-10). If you do not specify any size, the default size of 350 pixels (width) and 200 pixels (height) is used.

Insert the field function into your mailing using the image tag (`<img src="****\{\{fieldfunction}}****"/>`). Alternatively, you can create the field function directly with image tag, for example, `<img src="${barcodeCouponImage.getImageUrlFor($user.data.coupon, "twooffivebarcode", 9)}"/>`.

### Width and height size option

```velocity
${barcodeCouponImage.getImageUrlFor($user.data.RECIPIENTLISTFIELD, "BARCODETYPE", WIDTH, HEIGHT)}
```

### Line thickness size option

```velocity
${barcodeCouponImage.getImageUrlFor($user.data.RECIPIENTLISTFIELD, "BARCODETYPE", LINETHICKNESS)}
```

## [recipient-data.mdx](docId\:tKNrmCEQWLuLbI5HEBrSS)Generating QR codes

If you use the [coupon system](docId\:V5OJDVRBAoUBDge9djCe6) to generate machine-readable QR codes, you can use Velocity to create QR code field functions based on your recipient list fields.

To create QR code field functions, you need the following information:

- **Recipient list field**. Internal name of the recipient list field you want to use for the QR code.
- **QR code size**. Specify the QR code size using the *width and height* in pixels (100-1850).

Insert the field function into your mailing using the image tag (`<img src="****\{\{fieldfunction}}****"/>`). Alternatively, you can create the field function directly with image tag, for example, `<img src="${barcodeCouponImage.getImageUrlForQrCode($user.data.coupon, 300)}"/>`.

### Width and height size option

```velocity
${barcodeCouponImage.getImageUrlForQrCode($user.data.RECIPIENTLISTFIELD, WIDTHANDHEIGHT)}
```
