Aktionen - Export (Persistence) 

Page / - last modified by gru on 30.04.2021, 16:13 

Export (Persistence) 
last modified by gru
on 30.04.2021, 16:13

Table of Contents
Options
Importing form data from a persistence file

 
User interface for editing actions of type Export (Persistence).
Actions of type export (persistence) allow you to export the data of a form record, i.e. the data that has been submitted with the form. With a little bit of Javascript code, the exported data can be imported again later. This way it becomes possible to save form record data locally and restore it from a local backup. Filling form fields with data stored in an XML file is also possible via the actions of type Import form values from XML.
Options
Output file name
The name for the export file.
Attach file to form record
Determines whether the generated output file should be attached to the operation.
Importing form data from a persistence file
When you open a form and the form contains a non-empty upload field named fcp_persistence, or some other upload field contains a file whose file name without the extension is  fcp-persistence, form fields are pre-filled with the data form the persistence file.
The following example code makes it possible to realize this process with a button. The target of the form is set to its own URL when it is sent and all input fields except the upload field are deactivated. Subsequently, a submit of the form is executed which loads the contents of the file.
$('BUTTON[name="btnLoad"]').on('click', function(){
    $('.xm-form').attr('action', window.location);
    $('.xm-form input').not('[name=fcp_persistence]').attr('disabled', "disabled");
    $('.xm-form textarea').attr('disabled', "disabled");
    $('.xm-form select').attr('disabled', "disabled");
    $('.xm-form').submit();
});
$('[xn="fcp_persistence"] .img-uploaded-preview').visible(false);
Alternatively the following code can be used:
$('document').ready(function(){
   var nameOfTriggerButton= "btnLoad";

   var form = $("<form>", {
        action:"?",
        method:"post",
        enctype:"multipart/form-data"
    }).appendTo('body');

   var upload = $("<input>", {
        type:"file",
        name:"fcp_persistence"
    }).appendTo(form);

    upload.change(function(){form.submit()});
    $('BUTTON[name="'+nameOfTriggerButton+'"]').click(function(){upload.trigger('click')});
})
You may also download an example form illustrating this process and how to setup the workflow.