Tips & Tricks - Copy files via the WriteContainer
In this post, you will learn how to copy files using a WriteContainer.
You can download our sample application here and import it as usual.
Sample application in browser
When you open the sample application in your browser, you will see two tables on the homepage: The All Files table displays all the files you have uploaded. The Copy table lists all copies of the uploaded files.
Files can be uploaded on the "File" page.
After saving, the new files will be displayed on the home page. In the "Copy" table you can see the copies.
Click on "Edit" to open the input page to edit a file again. Click on "Save".
A copy of the edited file has been created, which you can now see in the "Copy" table.
Structure of the application in the "Applications" module
On the application home page, you can see the "All files" and "Copy" tables.
The application contains two data groups: The "File" data group, where the files are stored, and the "Copy" data group, where copies of the files are stored.
The "File" data group contains the "File" data field, which will later be used as a source. This data field is associated with the file selection element 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 new files are added and existing files are saved, and a copy of each is created simultaneously.
Switch to the "WriteContainer" tab there.
Here you will find the additional WriteContainer "Copy". In the WriteContainer properties, the data group "Copy" is selected.
In the binding properties, the data field "File" was selected as source.
In "Use with", "Add and change record" is selected.
Below this, the number of files to copy is specified, where the value "-1" copies all existing files (e.g. when uploading several files at once).
More general information about these settings can be found here.
When the original file is saved, the "Save" button processes both WriteContainers on the input page, one after the other. This means that first the original file is saved and then a copy of it is created and stored by the WriteContainer "Copy".
The order of the WriteContainers can also be changed here. A copy of the source file is saved first and then the (possibly modified) state of the source file in the "File" data group. In this way, a history of the source files can easily be generated, for example.