***
title: Moveworks Data Mapper Common Examples
excerpt: ''
deprecated: false
hidden: false
metadata:
title: ''
description: ''
robots: index
next:
description: ''
---------------
# **Overview**
In Moveworks' real-world scenarios, Bender examples are integral to streamlining processes within the Moveworks platform. These Bender examples are designed to help you write benders faster, showcase how obscure data can be molded into readable and friendly data, and improve your user experience and productivity.
# **Examples**
## Display a list of items in a single field
In many scenarios, especially within ticketing or request management systems, there's a need to display aggregate information in a concise and readable format. One common requirement is to list entities such as approvers for a request or tasks associated with a ticket in a single, easily digestible field. This example demonstrates how to accomplish this by aggregating a list of approver names into a single field named **`approvers`**.
### Context
Consider a situation where a system generates a payload response containing an array of approvers, each with their name, email, and an external identifier. The goal is to compile these names into a single string that lists all approver names, separated by commas, and display this list in a field called **`approvers`**.
### Given Payload Response
```json
{
"approver_list": [
{
"name": "John Doe",
"email": "john.doe@example.com",
"external_id": "123456"
},
{
"name": "Jane Smith",
"email": "jane.smith@example.com",
"external_id": "7891011"
},
{
"name": "Alex Johnson",
"email": "alex.johnson@example.com",
"external_id": "121314"
}
],
"etc...": {}
}
```
### Bender Mapping
```json
{
"approvers": {
"RENDER()": {
"template": "{{ users }}",
"args": {
"users": {
"EVAL()": {
"expression": "$CONCAT(users, ',')",
"args": {
"users": {
"MAP()": {
"items": "approver_list",
"converter": "item.name"
}
}
}
}
}
}
}
}
}
```
```yaml
approvers:
RENDER():
template: "{{ users }}"
args:
users:
EVAL():
expression: "$CONCAT(users, ',')"
args:
users:
MAP():
items: approver_list
converter: item.name
```
### Expected Result
```json
{
"approvers": "John Doe, Jane Smith, Alex Johnson"
}
```
***
## Return unique elements from an array
In many scenarios, especially within data processing or application development, there's a need to ensure that duplicate data is not unnecessarily processed or displayed. A common requirement is to extract and return only the distinct elements from a dataset, such as an array. This example demonstrates how to achieve this by filtering out duplicate entries and returning a list of unique elements.
### Context
Consider a situation where a system generates a payload response containing an array of elements, each of which might appear multiple times. The goal is to filter this array to return only the distinct elements, thereby eliminating any duplicates.
### Given Payload Response
```json
{
"data": [1, 2, 4, 3, 1, 4, 5, 6]
}
```
### Bender Mapping
```json
{
"items": {
"EVAL()": {
"expression": "sorted_records.$FILTER((x, i) => i == 0 OR x != sorted_records[i - 1])",
"args": {
"sorted_records": {
"SORT()": {
"items": "data",
"key": "item"
}
}
}
}
}
}
```
```yaml
items:
EVAL():
expression: "sorted_records.$FILTER((x, i) => i == 0 OR x != sorted_records[i - 1])"
args:
sorted_records:
SORT():
items: data
key: item
```
### Expected Result
```json
{
"items": [1, 2, 3, 4, 5, 6]
}
```
***
## Remove empty keys from the output mapper in a return statement
In some cases when working in Agentic Automation your API response will not return certain fields or return them as null and you don't want to provide it to the return statement at all so the LLM doesn't pull any context from the fact it's null.
### Context
Imagine a scenario in which a SharePoint system returns PO information and you only want to map specific values from the response to return in your Agentic Automation Plugin. Sometimes certain fields will be null or non-existent.
### Given Payload Response
```json
{
"data": {
"title": "PO1234",
"status": "Complete",
"email": null,
"country": "US"
}
}
```
### Bender Mapping
The mapping uses the **`EVAL`** operator to run the **\$FILTER()** DSL against the final object to remove any null keys. Within this EVAL the args we are passing through to build the object which we will run the FILTER against.
```yaml
- return:
output_mapper:
EVAL():
expression: sharepoint_info.$FILTER(x => x)
args:
sharepoint_info:
sp_title: data.title
sp_status: data.status
sp_user: data.email
```
### Expected Result
```json
{
"sharepoint_info": {
"sp_title": "PO1234",
"sp_status": "Complete"
}
}
```