Restore Form
Definition:
NDLLibrary.restoreForm(ndlParams)
Description:
Restore the form to its last saved state.
Parameters:
restoreForm requires the following two properties to be added to the default ndlParams object:
ndlParams.Id - Required
The unique ID identifying the saved data.
ndlParams.RestoreType - Optional
Specifies where the form was saved:
"database" | Form data was saved to a database. This is the default value if this property is not supplied. |
"cookie" | Form data was saved to a cookie on the user's local machine. This cookie has a lifetime of 1 day. |
"local" | Form data was stored to local HTML5 storage, if supported by the user's browser. |
Returns:
nothing
Code Sample:
Example using a page's onPageShow property to restore a saved form by retrieving the unique ID assigned to the save from a cookie:
function <formName>_<pageName>_onPageShow_<n>(ndlParams)
{
// Get the ID from the cookie
var id = NDLLibrary.getCookie("ndlSaveID");
// If we have an ID, perform the restore
if(id !== "")
{
ndlParams.Id =id;
return NDLLibrary.restoreForm(ndlParams);
}
}
Notes:
-
restoreForm allows you to restore a Form previously saved using saveForm.
-
This function uses the default ndlParams object because it requires the scope, hash and form properties contained in the default object. If you want to include this function within your own custom JavaScript, you will need to generate a JavaScript function from an Element's properties in order to obtain the default ndlParams and then modify that function or make its default ndlParams object available to other functions that you write.
-
If you are using cookies in your form, you will need to display an appropriate warning message within the form and allow users to refuse the use of cookies.
-
If the form was saved to a database, it will be saved to a table called NDLFXSave. This table will automatically be added to your project Datasources when you use saveForm or restoreForm and will be created when you publish your form, if it doesn't already exist. You can define the location of this database in the Publishing Profile used to publish your form.
-
If you have any File Upload Elements on your form, when the form is saved any file selections will be lost, due to browser security.
When the form is restored, File Upload Elements placed directly on the form will be empty and will display the Choose File button. The files will need to be reselected by the user. After restoring the form, the form will display the first page containing any File Upload Element marked as Required.
File Uploads performed from a Recordset's edit page, however, will still appear to have the data saved in the Recordset after the restore. However, the file names associated with the records displayed in the Recordset will have been lost from the File Upload Elements themselves and the user will need to re-edit each row and reselect the file to be uploaded. On the edit page any File Upload Elements will be empty and will display the Choose File button. If you only have File Upload Elements in Recordset edit pages, the form will not display the first page containing a File Upload Element after a restore.
If you have any File Upload Elements on your form, a warning message telling you that File Upload Elements are not supported with Save and Restore will be displayed when you publish the form, to remind you.
Using as Predefined Action in Event:
If you are assigning restoreForm to an Event as a predefined action, the Form Studiowill automatically generate a custom JavaScript function and load the custom JavaScript file in an editor. You will need to add to the Script to retrieve the unique ID for the save. For more details of how to do this refer to the question: How do I allow users to save a partially completed form and return to it later? in the FAQs section of the User Guide.
See also: