Export to persistence file


User interface for actions of type Export to persistence file.

Action of type Export to persistence file allows to provide the data of an form record as a persisted structure. This can be reloaded later to restore the form. This action and javascript code for loading the persisted values can thus be used to implement saving form data.

Parameters

Storage options for the created files

Output file name
Name of the output file.
Attach file to form record
If this option is selected, files created in this action will be attached to the form record. Otherwise, they are only available for other actions within the workflow processing in the same processing chain.

Action variables

Actions of type Export to persistence file provide Action variables which can be used in subsequent actions.

Standard action variables

[%$<action name>.SUCCESS%]
Return whether action was successfully executed. Returns Boolean (true/false).
[%$<action name>.RESULT%]
Return all results provided by the action in structured form.
[%$<action name>.ERROR_CODE%]
The error code thrown in case of an error in the action. Empty if no error occurred.
[%$<action name>.ERROR_MESSAGE%]
The thrown error message in the action's error case. Empty if no error occurred.

Action specific action variables

[%$<action name>.RESULT.fileSize%]
Size of the created persistence file, in bytes.
[%$<action name>.ERROR.message%]
Error code returned if the persistence file could not be written to the file system.

Import form data from export file

If a form is called and there is a non-empty upload field named fcp_persistence in the form or there is a file named fcp-persistence in another upload field, the values from the persistence file will be written to form when the form is delivered, thus pre-populating fields.

The following example code allows to realize this process with a button. Here, the form's target is set to its own URL on submit and all input fields except the upload field are disabled. Then a submit of the form is executed, through which the contents of the file are loaded.

$('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_validator.disable();
    $('.xm-form').trigger("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')});
})