Save and Restore a Survey JSON Schema

Edit in →

Survey Creator produces survey model schemas as JSON objects. You can persist these objects on your server or in the browser's localStorage so that users can restore them and continue designing the survey from where they left off. In this example, Survey Creator automatically saves survey JSON schemas in the localStorage. To try this functionality, modify the survey and reload the page—your changes will remain.

Persist Survey JSON Schemas

To save a survey JSON schema, implement the saveSurveyFunc function. It accepts two arguments:

  • saveNo
    An incremental number of the current change. Since web services are asynchronous, you cannot guarantee that the service receives the changes in the same order as the client sends them. For example, change #11 may arrive to the server faster than change #10. In your web service code, update the storage only if you receive changes with a higher saveNo.

  • callback
    A callback function. Call it and pass saveNo as the first argument. Set the second argument to true or false based on whether the server applied or rejected the change.

You can access the raw survey JSON schema using the SurveyCreatorModel's JSON property or its stringified version using the text property. Save the content of one of these properties to the preferred storage.

Enable Auto-Save

The saveSurveyFunc function is called each time a survey JSON schema needs to be saved. Users can run the save operation by clicking the Save button in the toolbar. Alternatively, you can enable auto-save. This feature starts the save operation when the survey JSON schema is modified.

To activate auto-save, set the isAutoSave property to true, as shown in this demo. Note that the Save button becomes unavailable. To avoid overloading the server with frequent requests, survey modifications are saved with a 500 ms delay. You can use the autoSaveDelay property to increase or decrease this value.

Your cookie settings

We use cookies on our site to make your browsing experience more convenient and personal. In some cases, they are essential to making the site work properly. By clicking "Accept All", you consent to the use of all cookies in accordance with our Terms of Use & Privacy Statement. However, you may visit "Cookie settings" to provide a controlled consent.

Your renewal subscription expires soon.

Since the license is perpetual, you will still have permanent access to the product versions released within the first 12 month of the original purchase date.

If you wish to continue receiving technical support from our Help Desk specialists and maintain access to the latest product updates, make sure to renew your subscription by clicking the "Renew" button below.

Your renewal subscription has expired.

Since the license is perpetual, you will still have permanent access to the product versions released within the first 12 month of the original purchase date.

If you wish to continue receiving technical support from our Help Desk specialists and maintain access to the latest product updates, make sure to renew your subscription by clicking the "Renew" button below.