Tips & Tricks - Copying files via 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.
Example application in the browser
If you open the sample application in the browser, you will find two tables on the start page: All files that you have uploaded are displayed in the "All files" table. 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. You can see the corresponding copies in the "Copy" table.
Open the input page by clicking on "Edit" to edit a file again. Click on "Save" there.
A copy of the edited file has been created, which you can now find in the "Copy" table.
Structure of the application in the "Applications" module
You will find the "All files" and "Copy" tables on the start page of the application.
The application contains two data groups: the "File" data group, in which the files are saved, and the "Copy" data group, in which the copies of the files are saved.
The "File" data group contains the "File" data field, which is later used as the 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 is later used as the target.
Here you can see the "File" input page, where new files are added and existing files are saved and a copy is created at the same time.
Switch to the "WriteContainer" tab there.
Here you will find the additionally created WriteContainer "Copy". The "Copy" data group is selected in the WriteContainer properties.
The "File" data field was selected as the source in the properties of the binding.
In "Use with", "Add and change data record" is selected.
The number of files to be copied is defined below this, whereby the value "-1" copies all existing files (e.g. when uploading several files at the same time).
Further general information on these settings can be found 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 saved first and then a copy of it is created using the WriteContainer "Copy" and stored accordingly.
The order of the WriteContainers can also be changed here. This would first save a copy of the source file and then the (possibly changed) status of the source file in the "File" data group. In this way, a history of the source files can easily be generated, for example.