How to store record as a draft in Database.

How to store record as a draft in Database.

02 Nov 2021
0 Comments
How to store record as a draft in Database.

Why do we need to store data as a draft in the table?
We can add a Save as Draft function to a form, which gives the user the ability to save the information already entered so that they can complete and submit the form later.
 

Following are the steps to store record as a draft:
 

Step 1: Add a new field like “save_as_draft” as a boolean in the table where you want to store data as a draft.
 

Step 2: Set default: true for field “save_as_draft” in Database.
store-record

 

Step 3: We can show draft and non-draft records in 2 different tables by applying conditions like
for show draft record we can apply condition: if table_name.save_as_a_draft == true
for show non-draft record we can apply condition: if table_name.save_as_a_draft == false

store-as-record

 

Step 4: Create a method and update the “save_as_a_draft” field after clicking on the button, which you want to update the value of the “save_as_a_draft” field on that click from the table.
store-as-record-in-database

 

Step 5: We get 2 different tables for draft records and non-draft records from the same table in the database.
 

Conclusion: By using the save as a Draft concept, users can fill the form according to the data that they have at the current time for filling the form. After all, data fill out then users can save their form-filled data as permanent.




Leave a comment: