ASPX templates
Version 4.x > ASPX templates > BizForm Records disappearing View modes: 
User avatar
Member
Member
mrogers-brainloaf - 12/2/2009 4:58:20 PM
   
BizForm Records disappearing
we have a system we have developed for a client that uses BizForms heavily for data capture from service agents around the US. The come to the site, open up a page that displays the correct bizForm based on some logic, then they save the bizform. This is all working properly and the records appear properly. They also export into excel properly. But in the past few weeks, the client has discovered that a couple of the records have gone missing from the bizForm Tables. This has happened on multiple biz forms. The forms have not been edited or manually deleted as far as we can tell. They have not be saved again either.

here is the way I display the bizForm:

bizForm.FormName = form.FormName;

// could this be it? for new forms with recordid zero would this blow something up?
bizForm.ItemID = activity.RecordId;

//bizForm.BasicForm.SubmitButton.Text = "Save";
bizForm.OnAfterSave += new CMS.FormControls.BizForm.OnAfterSaveEventHandler(bizForm_OnAfterSave);
bizForm.BasicForm.SubmitButton.Text = "Save and Submit Final";

And then here is my OnAfterSave:

string bizFormName = form.FormName;
string siteName = "BlankSiteASPX";

// Read BizForm definition
BizFormInfo bfi = BizFormInfoProvider.GetBizFormInfo(bizFormName, siteName);

if (bfi != null)
{
// Read data type definition
DataClassInfo dci = DataClassInfoProvider.GetDataClass(bfi.FormClassID);

if (dci != null)
{
// Get all bizform data
GeneralConnection genConn = ConnectionHelper.GetConnection();
//DataSet ds = genConn.ExecuteQuery(dci.ClassName + ".selectall", null, null, null);

// Get ID of the first record
int formRecordID = bizForm.ItemID;
// Get the record with ID of the first row record
DataClass formRecord = new DataClass(dci.ClassName, formRecordID, genConn);

if (!formRecord.IsEmpty())
{
// Set new field values
formRecord.SetValue("RepId", activity.User.UserId);
formRecord.SetValue("RepName", activity.User.Fullname);
formRecord.SetValue("StoreName", activity.LocationName);
formRecord.SetValue("StoreNum", activity.Location.StoreNumber);
formRecord.SetValue("City", activity.Location.StoreCity);
formRecord.SetValue("State", activity.Location.StoreState);
formRecord.SetValue("mplid", activity.Id);

formRecord.SetValue("ScheduleDate", activity.ScheduleDate);
formRecord.SetValue("ServiceByDate", activity.ServiceByDate);
formRecord.SetValue("ScheduleDate", activity.ServicedDate);

// Save updates in the database
formRecord.Update();

//lblInfo.Text = "The first record was updated successfully.";
}
//else
//{
// lblInfo.Text = "No data found.";
//}
}
}

All of this seems to record properly, but the records seem to disappear at somepoint. Can you see anything I am doing wrong?

User avatar
Kentico Consulting
Kentico Consulting
kentico_mirekr - 12/4/2009 7:48:10 AM
   
RE:BizForm Records disappearing
Hi,

I do not see any problem in your custom code, so it sounds really strange that some of the records from your BizForm tables are missing. However, I would recommend you to use OnBeforeSave event of your BizForm to save your custom data into BizForm. Please find example code on how to access the BizForm fields in OnBeforeSave event below:


bizForm.BasicForm.DataRow["RepName"] =


Best regards,
Miroslav Remias.

User avatar
Member
Member
mrogers-brainloaf - 12/4/2009 8:09:06 AM
   
RE:BizForm Records disappearing
thanks, that is much cleaner. I didn't like the way that sample code modifies an existing record. I will report what is going on with the delete when I figure it out.