Portal Engine Questions on portal engine and web parts.
Version 4.x > Portal Engine > Restoring BizForm data if user returns to it View modes: 
User avatar
Member
Member
Steve-Appetere - 4/17/2009 11:41:38 AM
   
Restoring BizForm data if user returns to it
Hi.

I am planning to use BizForms so that a customer can create surveys for logged-in users to complete.

The default behaviour for a BizForm is that the same user can fill in the form & submit it multiple times (which is appropriate for a contact form, say).

Instead of this behaviour, I would like to set up the form so that once the user has filled it in & submitted it, if he returns to the form in the future, the form will be populated with those same details (possibly greyed out).

It looks like this should be possible by creating a custom BizForm webpart & modifying the code - however, the solution needs to be general enough so that it will restore data for whichever survey (BizForm) happens to be viewed by the user.

Can you please advise if this is feasible with BizForms?

If so, if you can give me an outline of the steps needed to achieve this, that would be much appreciated.

Thank you,

Steve

User avatar
Kentico Developer
Kentico Developer
kentico_martind - 4/29/2009 10:20:18 AM
   
RE:Restoring BizForm data if user returns to it
Hi Steve,

If you use Kentico CMS 4.0 you can use alternative forms feature to display e.g. labels instead of texboxes if any data has been already submitted. Please follow procedure bellow:

1) Add field into your BizForm to store ID of user who submitted the form. You can set 'Show on public form' property of this field to false and set value for the field automatically in OnBeforeSave event handler. You can use CMS.CMSHelper.CMSContext.CurrentUser.UserID property to get ID of current user.

2) You will need to modify copied BizForm web part so it checks if current user has already submitted any record and if so it sets alternative form for BizForm that will display labels instead of textboxes.

Best Regards,

Martin Dobsicek

User avatar
Member
Member
Steve-Appetere - 5/7/2009 5:31:54 AM
   
RE:Restoring BizForm data if user returns to it
Thanks for the guidance.

For point 1) I have this working using:

protected void viewBiz_OnBeforeSave()
{
viewBiz.BasicForm.DataRow["UserId"] = CMSContext.CurrentUser.UserID;
}


For point 2) I am trying to work out the most efficient way of repopulating the form with data, if a user has already completed the form.

One approach could be to set the value of each control in code, using similar code to Making BizForm fields inactive after submitting.

But is there an easier way? For example if viewBiz.BasicForm.DataRow is populated with the existing data in one of the control events, will the control automatically use these values to populate the form? If so, which event would be the best place?

Thanks again,

Steve

User avatar
Kentico Developer
Kentico Developer
kentico_helenag - 5/13/2009 8:26:55 AM
   
RE:Restoring BizForm data if user returns to it
Hi Steve,

if I get your point you could use the similar approach as is in this knowledge base article - only you would retrieve the information from database instead of query strings. Please see here: http://devnet.kentico.com/Knowledge-Base/Web-parts---Controls/Setting-default-values-for-BizForm.aspx

Best regards,
Helena Grulichova