---
title: "\"Copy to\" Actions"
slug: "copy-to-actions"
updated: 2025-02-13T10:46:44Z
published: 2025-02-13T10:46:44Z
canonical: "documentation.encodify.com/copy-to-actions"
---

> ## Documentation Index
> Fetch the complete documentation index at: https://documentation.encodify.com/llms.txt
> Use this file to discover all available pages before exploring further.

# "Copy to" Actions

### Copy to FTP Server

---

Configure copy to FTP Server action handling by specifying URL of the FTP server, Login and password. You can check whether FTP connection is successful by clicking the Test FTP connection button. The *Autocreate directories* checkbox will create the directory if it was not created on FTP server but specified in the *Server path* field.

There are two options to export item data on action triggering: text export and file export.

File export option is available for all actions except for Delete. By selecting the file in the *File* field and specifying the *Server path*, you configure the action to copy a file from the specified field to the folder on FTP server defined in *Server path* field.

Starting from version 11.0.0. it is also possible to select the template engine (Encode/Velocity) and specify the output file name. Velocity can be used both for specifying output file name and the content of the text export.

If output file name is not specified, the original file name will be exported.

*Example of Output File Name using Velocity template:*

```plaintext
${CurrentItem.fieldValue('Metadata')}
```

For more information about using velocity see [Functions and Variables](/v1/docs/ui-event-actions).

*Example of using velocity function (foreach) for processing an array of multiple files uploaded to the multiple file fields.*

```plaintext
#set($files =${CurrentItem.findFilesInMediaHolder(2492)})

	
#foreach($file in $files)
		$file.toUrlLink(true)
#end
```

> [!WARNING]
> The server path must be specified as an absolute path (with preceding slash /) from the server root, f.e.:
> 
> ```plaintext
> /home/someuser/Files/exported
> ```

Text export option is available for all types of actions. Do the following to configure text export:

1. Select the *Text export* check box to configure text export on action triggering.
2. In the *Server Path* field, specify the path to the folder on FTP server where the text file will be copied to on action triggering.
3. In the *Output format*field specify the format of the file that will be exported on action triggering. The following output formats are currently available for selection: xml, html, txt, comma-delimited, tab delimited, custom (starting from version 11.3.0). The default output format for the files is xml, when changing the default format to any other of the above-mentioned extensions information window warns you that after changing the output format, the text entered in the *Text File Formatting* box will be changed correspondingly. The extension of the output file name will also change in accordance with the selected format. Selecting "Custom format" allows you to enter the extension needed. Note, that "Output File Name" parameter should not contain extension in it's name. Extension is automatically added on file export depending on the selected output format or specified format for the custom one.
4. Select the encoding for the text from the drop-down box next to the *Output format* field.
5. "Template Engine Escape Strategy" configuration option (available from v. 11.3.0) allows to manually define encoding for the file being exported. Configuration options is applicable only to actions using "Encode" template engine, as Velocity provides its own encoding methods. For each format escaping strategy needs to be selected. Available options: "Escape xml", "Escape html". No option selected means no encoding will be applied and data will be exported as is.
6. *Text File Formatting* represents the text itself that will be exported. In addition to typing, you can use variables that on action triggering will be replaced by the actual data. The list of variables also includes all fields that are available in the module. All valid variables are listed at the bottom of the Content box. **Note!** For "Delete"-type actions, the following syntax should be used to fetch field values:

```plaintext
$CurrentItem.changes().oldValue(yourFieldId)
```
7. Enter the name of the file to be exported in the *Output file name* field. By default, the field is prefilled with the name of the Name field in the module and can be easily overwritten.

![Screenshot_2022-04-04_at_09.29.05.png](https://cdn.document360.io/3a63e0a8-1221-4570-aaa1-d43f9b95a612/Images/Documentation/4753403334173.png)

*Configure Copy to FTP action handling*

### Copy to File System

---

Copy to file system action handling copies media and text files to the directories in file system specified in Server path fields in action setup. The setup of the Copy to file system action handling is almost the same as for Copy to FTP server. The only difference between them is that for Copy to File System action handling, you do not specify FTP URL, login and password. All the rest configuration fields are the same. The advantage here is that if you decide to change action handling after all the export fields are configured, the entered data will be saved for all fields that these action handlings have in common.

![Screenshot_2022-04-04_at_09.28.23.png](https://cdn.document360.io/3a63e0a8-1221-4570-aaa1-d43f9b95a612/Images/Documentation/4753395474333.png)

*Configure Copy to File System action handling*

To edit an Action, follow these steps:

1. Click the *Edit* icon next to the Action that you want to edit.
2. In the dialog box that opens, modify the Action as necessary.

To delete an Action, click the *Edit*icon next to it, and then click *Delete* on the toolbar of the dialog box that opens.

> [!NOTE]
> Server Path Configuration
> 
> It is necessary to keep in mind certain differences when configuring the Server path for “Copy to File System” and “Copy to FTP Server” action handlings.
> 
> First, we should distinguish two types of paths: **absolute** and **relative**.
> 
> The **absolute path** specifies folder location beginning from the root and always begins with `/`. For example: if we specify the following path: `/user`, it means that the file will be placed to the `user` folder which is located under root.
> 
> The **relative path** specifies a location in relation to the current location. The current location can be either the place where the worker was started or home directory — place the user logged in from. The latter depends on the server setup. For example, if the current directory on the server is set up as a home directory, the absolute path will be `/home/{user}/folder_name/file.ext`. A relative path will be the following: `folder_name/file.ext`.
> 
> For “Copy to File System” action handling the user can specify either absolute or relative path.
> 
> **For example:**
> 
> - Absolute path: `/home/{user}/folder_name/file.ext`
> - Relative to current directory: `folder_name/file.ext`
> 
> When setting up the action with “Copy to FTP Server” action handling, the path should always be **absolute**.

### Copy to HTTP Server

---

Configured Copy to HTTP Action triggers a request that is sent to the HTTP server. Configuring the action, you can choose between request methods: GET, POST, PATCH,PUT, DELETE.

The action supports HTTP and HTTPS protocols.

#### Action Settings

| Parameter | Description |
| --- | --- |
| Template engine | Encode, Velocity > [!WARNING] > To see examples of velocity functions, please see an article: [Functions and Variables](/v1/docs/ui-event-actions) |
| HTTP URL | Request URL that can be processed by the external server. For example: ```plaintext http://httpbin.org/post ``` |
| HTTP Method | GET, POST, PATCH, PUT, DELETE |
| Authenticate With Connected Service | Enables authentication by selected connected service. Currently the 2 types of the authenticating connected service types are available: - [OAuth2 connected](/v1/docs/custom-oauth2-service-custom-http) service - HTTP Request Headers |
| Connected service | Select authenticating connected service |
| Content Type | Type of the content to be sent by POST or PUT request methods. - application/json - application/x-www-form-urlencoded - multipart/form-data |
| Multipart File Parameters | Available when "multipart/form-data" is selected in the **Content** type selectbox. This allows to configure support of multipart file upload in requests sent in HTTP action. The **Source Holder** drop down allows to select the Media file holder as a source of file for the request. Both original and custom media holders configured in the module will be available for selection. ![File_Output_Name.png](https://cdn.document360.io/3a63e0a8-1221-4570-aaa1-d43f9b95a612/Images/Documentation/4708744995229.png) **Please, note!** Selecting custom media holder as a file source will not work on new item creation or upload of the new file(s), as previews will not be generated before the action will be triggered which means that the file will not be sent. **File Output Name**input field allows to specify an alternative filename so that it can be used as a unique key when integrating with 3rd party applications.If the property is empty - original filename is used. Formulas to concatenate file name from few fields are supported. To see examples of velocity functions, please see an article: [Functions and Variables](/v1/docs/ui-event-actions) As an example: - *if "Velocity" template engine is selected ${CurrentItem.fieldValue('Name')}-$CurrentItem.getId() formula allows to insert value from "Name" field and itemId in filename* **NOTE:** file name is allowed to use for both single and multiple file field - For single file field or multi-file field with limit of 1 the specified variables are used - For multi-file field with limit greater than 1 {number} suffix is added to file name |
| Request Body | Used when **application/json** content type is selected. Specify the valid JSON here. It is possible to use placeholders inside the JSON, so you can send the specific item's data to the server. For example: ```plaintext { "id": 6290, "name": "TestName" } ``` [![json_request.png](https://cdn.document360.io/3a63e0a8-1221-4570-aaa1-d43f9b95a612/Images/Documentation/360027716312.png)](https://cdn.document360.io/3a63e0a8-1221-4570-aaa1-d43f9b95a612/Images/Documentation/360027716312.png) **Note!** For "Delete"-type actions, the following syntax should be used to fetch field values: ```plaintext $CurrentItem.changes().oldValue(yourFieldId) ``` |
| Request Parameters | Used when **application/x-www-form-urlencoded** content type is selected. You can create the pairs "Name-Value" which will be sent as encoded form data. It is possible to use placeholders inside the parameter value [![form_request.png](https://cdn.document360.io/3a63e0a8-1221-4570-aaa1-d43f9b95a612/Images/Documentation/360027712451.png)](https://cdn.document360.io/3a63e0a8-1221-4570-aaa1-d43f9b95a612/Images/Documentation/360027712451.png) |
| Request Headers | Allows adding the "Name-Value" pairs which will be sent as request headers on action triggering. It is possible to use placeholders inside the parameter value. ![Screenshot_2019-12-06_at_16.33.58.png](https://cdn.document360.io/3a63e0a8-1221-4570-aaa1-d43f9b95a612/Images/Documentation/360045008351.png) |
| Map Response Data | Allows mapping the JSON response to encode fields of the item. **"Skip Empty Response"**checkbox It allows to control whether empty JSON pointer are returned as warnings or ok to reduce noise on logs - When TRUE it should treat empty responses as OK in logs - When FALSE it should continue to treat empty responses as a warning in logs ![21a1d7f5-2f83-457a-a6f2-8806522b5d93.png](https://cdn.document360.io/3a63e0a8-1221-4570-aaa1-d43f9b95a612/Images/Documentation/15139530418717.png) As per version 11.0.0 the following field types are supported in response mapping: - text - date (date, week, month, datetime) - site locale/TZ applied - options (single select fields only) - module links (single and multiple only by option ID) - integer - site locale/TZ applied - decimal - site locale/TZ applied As per version 11.3.0 the following *additional* field types are supported in response mapping: - Single file fields as response values (11.3.0) - Multi file fields as response values (11.3.0) ![Map_Response_Data_11.3.0_onwards.png](https://cdn.document360.io/3a63e0a8-1221-4570-aaa1-d43f9b95a612/Images/Documentation/5370784912925.png) It is possible to map the response value to a singe file or multi file field both on existing record ( Update ) and on new record ( Create ). Media Converters can be used for Single file field only. If Version Control is enabled a new version is created each time item is updated. Currently this is only available for Single file fieds. The Mapping works for both 'Encode' and 'Velocity' as Template engine. When file name is not specified on the 'Configuration' field in the Action, then original file name is used as returned by API call. - Mapping multiselect fields with string values (11.3.0) This enabled the option to set multi-module link fields by string values ![Configuration Response mapping multiselect Fields_new.png](https://cdn.document360.io/3a63e0a8-1221-4570-aaa1-d43f9b95a612/Images/Documentation/15139496867229.png) Checkbox in Configuration for to select 'Map Id' or 'Map Value', is only shown when Field type is ModuleData or CheckBox or MultiSelect or SelectBox or RadioBox or Status. Example of the Request Body for above: *{ "ClientsMulti": ["Client 1","Client 2","Client3"],* *"checkbox": ["ch1","ch2","ch3"]* *}* #### **Keywords in Response Path:** Using the mapping, it will be easy to check the request status and receive the data. It is possible to use such keywords in Response Path: - `statusCode` — HTTP status code of the response; - `headers.` — inserts value of the specified response header parameter; - `body` — inserts the entire response body to the mapped field; **Parameters:** **Starting from version 17:** - `$.param1` or `$['param1']` — inserts the value of the specified parameter in the JSON body From version 17.0.0 onward ***Version 9.95.0 - 16.0.5:*** - `/` — inserts the value of the specified parameter in the JSON body. *For versions earlier than 17.0.0* - `//`— inserts the value of the nested parameter from the inner response object in the JSON body **Before version 9.95.0:** - - *For versions earlier than 9.95.0 -*`body.` - - *For versions earlier than 9.95.0 -*`body..`*inserts the value of the nested parameter from the inner response object in the JSON body.* ***Response Path in versions 16 and earlier:*** *e.g.*`/fields/1/options/0/value` ![c98bb52344.jpg](https://cdn.document360.io/3a63e0a8-1221-4570-aaa1-d43f9b95a612/Images/Documentation/360049943171.png) ***Response Path from version 17 onward:*** *e.g.*`$.fields[1].options[0].value`*OR*`$['fields'][1]['options][0]['value` **![c98bb52344_new.png](https://cdn.document360.io/3a63e0a8-1221-4570-aaa1-d43f9b95a612/Images/Documentation/15139496869149.png)** **Example** > Having the response: > > ```plaintext > Status: 200 OK > Date: Tue, 30 Apr 2019 09:24:26 GMT > Content-Type: application/json;charset=UTF-8 > [ > { > "id": 1, > "name": "Leanne Graham", > "username": "Bret", > "email": "Sincere@april.biz", > "address": { > "street": "Kulas Light" > }, > "phone": "1-770-736-8031 x56442", > "company": { > "name": "Romaguera-Crona" > } > }, > { > "id": 2, > "name": "Ervin Howell", > "username": "Antonette", > "email": "Shanna@melissa.tv", > "address": { > "street": "Victor Plains" > }, > "phone": "010-692-6593 x09125", > "company": { > "name": "Deckow-Crist" > } > } > ] > ``` **From Version 17 onward:** We can fetch the data to the fields using Response Path keywords. In the current example they will return: - `$[0].name` or `$[0]['name']` → Leanne Graham - `$[1].name` or `$[1]['name']` → Ervin Howell - `$[-1].name` or `$[-1]['name']` → Ervin Howell (-1 = last element) - `$[1].address.street `or `$[1]['address']['street']` → Victor Plains The *dot-separated* notations are preferable and recommended for usage for properties with simple names. But *notations with brackets* are safer (for example with property names with dots, or names that contain a lot of characters. It is now possible to extract a property from the last object of json array using the`[-1]` in the path (when the number of objects in the array is unknown). For more details go to the [documentation (version 17 and later)](https://github.com/json-path/JsonPath). **Versions 9.95-16.0.5:** We can fetch the data to the fields using Response Path keywords. In the current example they will return: - `statusCode` → 200 - `headers.date` → "Fri, 03 May 2019 12:23:32 GMT" - `/0/name ` → Leanne Graham - `/1/name` → Ervin Howell - `/1/address/street` → Victor Plains **Note!** Value will not be copied to the target field if Response Path contains character '#', because it's referenced value is the root of the document. For more details go to the [documentation (version 16 or earlier).](https://datatracker.ietf.org/doc/html/rfc6901) |
| Notifications will be sent after HTTP Copy | ![19507bd1b8.jpg](https://cdn.document360.io/3a63e0a8-1221-4570-aaa1-d43f9b95a612/Images/Documentation/10962847097501.png) Field contains a list of Notifications Rules with Sub-Type 'Copy to HTTP Action' created on the site. For more details [go to the documentation.](/v1/docs/automation-rules#notifications-rules) |

**Note!**

> [!WARNING]
> Before configuring the HTTP action to send the requests, make sure that your server supports selected HTTP methods.
> 
> Also, pay attention to server encoding settings in order to accept Unicode characters that are passed in request correctly. Make sure your server processes requests in UTF-8 encoding.

Starting from v.14.1.0 next logic matrix was implemented for updating files in Single/Universal/Multiple file fields:

**Single file field**

- empty before - new file added
- not empty and versions not enabled - clean old file + add new file
- not empty and versions enabled - add file with new version

**Universal file field(multiple file field with limit=1)**

- empty before - new file added
- not empty versions not enabled - clean old file + add new file
- not empty and versions enabled - add file with new version

**Multiple file field(limit>1)**

- empty/not empty - always add new
- for ability to clean old file + add new file - added new request param `fd&lt;ID&gt;_clearPreviousFileValues where ID - id of updated file field in target module`

![ClearPreviousFileValues.png](https://cdn.document360.io/3a63e0a8-1221-4570-aaa1-d43f9b95a612/Images/Documentation/9194772219165.png)

- for ability to upload file as new version - added new request param `fd&lt;ID&gt;_versionChainId where ID - id of updated file field in target module`

![versionChainId_in_config.png](https://cdn.document360.io/3a63e0a8-1221-4570-aaa1-d43f9b95a612/Images/Documentation/9194820296989.png)

**Please note**: upload of file versions within various chains simultaneously is not supported in one "Copy to HTTP" action.

[**SortTool in Velocity:**](/v1/docs/insert-field-values-from-the-linked-modules-into-actions-velocity-template) Use of [**SortTool**](https://velocity.apache.org/tools/2.0/apidocs/org/apache/velocity/tools/generic/SortTool.html)in Velocity is been enabled in version 19. This tool makes it easy to organize and manage lists of items in your templates.

#### Classes for Debugging

- dk.encode.ebms.core.jms.listeners.HttpMessageListener
- dk.encode.ebms.connections.service.impl.ConnectedAccountServiceImpl
- org.apache.http.wire
