Tips & Tricks - Copying Files Using WriteContainer

In this post, you'll learn how to copy files using a WriteContainer.

You can download our sample application here and import it as usual.

Sample Application in the Browser

When you open the sample application in your browser, you'll see two tables on the home page: The "All Files" table displays all the files you've uploaded. The "Copy" table lists all copies of the uploaded files.

You can upload files on the "File" page.

After saving, the newly created files will appear on the home page. In the "Copy" table, you can see the corresponding copies.

Click "Edit" at to open the input page and edit a file again. Click "Save" there.

A copy of the edited file has been created; you can now find it in the "Copy" table.

Setting Up the Application in the "Applications" Module

On the app's home screen, you'll find the "All Files" and "Copy" tables.

The application contains two data groups: the "File" data group, which stores the files, and the "Copy" data group, which stores copies of the files.

The "File" data group contains the "File" data field, which will be used as a source later on. This data field is linked to the file selection element, which can be used to upload the original files.

The "Copy" data group contains the "Copy" data field, which will be used as the destination later.

Here you can see the "File" input page, where you can add new files and save existing files while creating a copy of each one at the same time.

There, switch to the "WriteContainer" tab.

Here you'll find the additional WriteContainer named "Copy." The "Copy" data group is selected in the WriteContainer properties.

In the binding properties, the "File" data field was selected as the source.

"Add and modify records" is selected under "Use for."

This setting specifies the number of files to copy; a value of "-1" copies all existing files (e.g., when uploading multiple files at once).

You can find more general information about these settings here.

When saving the original file, the "Save" button processes both WriteContainers on the input page one after the other. This means that the original file is first saved, and then a copy of it is created using the "Copy" WriteContainer and saved accordingly.

The order of the WriteContainers can also be changed here. This would first save a copy of the source file and then save the (possibly modified) version of the source file in the "File" data group. This way, for example, it would be very easy to generate a history of the source files.