As many of you may know, FEB has a Save as Draft feature. This feature, as of 8.6, has a limitation where you can only save a draft if you are an authenticated user. This is a logical limitation as FEB needs to know who the user is in order to associate the draft to them.
I had a request for a Save as Draft feature for an anonymous survey. I put some thought in to a solution and I wanted to document it here for anyone else that might be interested in such a feature.
Solution Description
The end solution from the user perspective can be described as:
The user is filling out the form and realizes they need to step away from the computer so they click the Save as Draft button. A prompt will appear where they enter an email address (unvalidated). They will receive an email that contains a link to the draft, clicking on that link will launch the draft form and they can continue filling out the form.
Implementation Details
There are only a few pieces to this solution which makes it pretty easy to implement in your application.
Now for the little bit of javaScript required to glue it all together. In the Application...Settings...Events (in 8.6.2 - click the properties of the form, click the Events tab and click the onLoad event) add the Recursive Function from the Wiki. Set your processItem function to:
app.getSharedData().processItem = function(item) { if(item.getBOAttr() !== null) { //turn off the required state of the field item.getBOAttr().setRequired(false); } } |
In the form validateButtonPressed event add the following code:
//show dialog to capture users email to send link to form if(pButtonTitle === "S_SaveAsDraft") { //set all required items to not required app.getSharedData().getItem(form, app.getSharedData().processItem); var userEmail = prompt("Provide Email Address, an email will be sent with a link to access this draft"); var r = false; if (userEmail !== null) { BO.F_SingleLine0.setValue(userEmail); r = true; } return r; } |
Limitations
A sample application, built in 8.6, is attached to this article.