Portal Engine Questions on portal engine and web parts.
Version 6.x > Portal Engine > Overriding the Biz Form View modes: 
User avatar
Member
Member
ryans-tushaus - 6/10/2013 6:15:38 PM
   
Overriding the Biz Form
I'm overriding the Biz Form and, in the OnAfterSave function, I would like to retrieve the ID of the form record that was just inserted. Is there a way that I can retrieve this value without querying the database table? Querying the database table for the maximum ID would probably work 99.9% of the time but may return the incorrect value if more than one user submits the same form at the same time.

User avatar
Kentico Legend
Kentico Legend
Brenden Kehren - 6/10/2013 10:37:47 PM
   
RE:Overriding the Biz Form
I have this in a custom table form (which uses Biz Forms). The syntax is for v7 but should work for v6 as well.
protected void customTableForm_OnAfterSave(object sender, EventArgs e)
{
CustomTableForm ctf = (CustomTableForm)sender;
// need to programatically get the primary key column
IDataClass idc = DataClassFactory.NewDataClass("your.class.name");
// get the id of the last inserted item
int lastInsertedId = ValidationHelper.GetInteger(ctf.BasicForm.Data[idc.IDColumn], -1);
}

User avatar
Member
Member
ryans-tushaus - 6/11/2013 2:02:37 AM
   
RE:Overriding the Biz Form
Exactly what I needed. Thanks for the sample code!