Creating a new record

  Previous topic Next topic JavaScript is required for the print function Mail us feedback on this topic! Mail us feedback on this topic!  

The sample code below demonstrates how a new record can be added to a BizForm using the API.




using CMS.FormEngine;

using CMS.SettingsProvider;

using CMS.DataEngine;

using CMS.GlobalHelper;




      string bizFormName = "TestingSiteContactUs";

      string siteName = "CMSTestingSite";


      // Read BizFrom definition

      BizFormInfo bfi = BizFormInfoProvider.GetBizFormInfo(bizFormName, siteName);


      if (bfi != null)


          // Read data type definition

          DataClassInfo dci = DataClassInfoProvider.GetDataClass(bfi.FormClassID);


          if (dci != null)


              GeneralConnection genConn = ConnectionHelper.GetConnection();

              // create a new record in memory (new DataClass object)

              DataClass formRecord = new DataClass(dci.ClassName, genConn);


              // Insert some data

               formRecord.SetValue("FirstName", "Alice");

               formRecord.SetValue("LastName", "Cooper");

               formRecord.SetValue("Email", "");

               formRecord.SetValue("Message", "Hallo world");

               formRecord.SetValue("FormInserted", DateTime.Now);

               formRecord.SetValue("FormUpdated", DateTime.Now);


              // Insert the new record in the database



              // Update number of entries in BizFormInfo






Page url: