Adding Fields to Custom Objects
You can modify custom objects after implementation by completing each of the
following procedures:
- Add fields to the new object within the Cartella UI.
- Edit form definition fields within Microsoft SQL Server Management Studio (SSMS).
- Update [Site_Root]\App_Code\[Custom_Object_Name].cs.
Warning
Do not edit the SQL scripts that were generated by Object
Builder, as this may render your Cartella site inoperable.
Adding Fields in UI
To add fields to the new object in the Cartella UI:
- Log in to Cartella.
- Navigate to Settings > Customize > Manage Fields.
- Select the custom object from the Field Management drop-down list.
- Click Add Fields.
- At the bottom of the Fields list, enter values for
Name, Unique ID, and
Field Type.
- If the new field is required, enable the Required option.
- Click Save.
Editing Form Definition Fields in SSMS
To edit form definition fields:
- Open the Cartella database in Microsoft SQL Server Management Studio (SSMS).
- In SSMS, navigate to the dbo.Table_EditFormDefinition_Fields table within your Cartella database.
- Right click the dbo.Table_EditFormDefinition_Fields table, then select Edit Top 200 Rows.
- Scroll to the end of the table and provide values for the new field,
manually.
- Close SSMS.
Updating Custom Object Controller in App_Code
To update the object's controller:
- Navigate to [Site_Root]\App_Code.
- Open [Custom_Object_Name].cs in Visual Studio or other ASP.NET editor.
- In the custom object's controller, update the code to include the new
property.
In CustomModule1.cs, each code block needing an update is called out in a comment, where Field2 is the new property.
namespace Cartella.Classes { using System; using Cartella.Interfaces; using Cartella.Support; using System.Data.SqlClient; using System.Collections.Generic; using System.Linq; public partial class CustomModule1 : Cartella.Classes.FolioItemBase, ICustomModule1 { public CustomModule1() { } public CustomModule1(Cartella.Interfaces.IFieldCollection fields) : base(fields) { } public override System.Type[] AllowedChildrenTypes { get { return new Type[0]; } } public string Field1 { get { return this["EX_Field1"]; } set { this["EX_Field1"] = value; } } //------------------------------------------------------------------------------ // Add new property here: //------------------------------------------------------------------------------ public string Field2 { get { return this["EX_Field2"]; } set { this["EX_Field2"] = value; } } private string GetFriendlyName() { return "Custom Module 1 "; } } public class CustomModule1Manager : FolioItemManager<CustomModule1>, ICustomModule1Manager { public CustomModule1Manager(Cartella.Interfaces.ISiteManager siteManager) : base(siteManager) { } public CustomModule1Manager() { } public new virtual ICustomModule1 Select(Cartella.Interfaces.IFieldCollection fields) { return base.Select(fields); } public new virtual ICustomModule1 Create(Cartella.Interfaces.IFieldCollection fields) { return base.Create(fields); } public new virtual ICustomModule1 SelectSingle(string id) { return base.SelectSingle(id); } //------------------------------------------------------------------------------ // Add new property here: // public ICustomModule1 CreateCustomModule1(string name, string description, string Field1, Cartella.Interfaces.IEntity parentEntity) { //------------------------------------------------------------------------------ public ICustomModule1 CreateCustomModule1(string name, string description, string Field1,string Field2, Cartella.Interfaces.IEntity parentEntity) { FieldCollection fields = new FieldCollection(); fields.Add(new Field(new FieldDefinition("Name"), name)); fields.Add(new Field(new FieldDefinition("Description"), description)); fields.Add(new Field(new FieldDefinition("EX_Field1"), Field1)); //------------------------------------------------------------------------------ // Add new property here: //------------------------------------------------------------------------------ fields.Add(new Field(new FieldDefinition("EX_Field2"), Field2)); CustomModule1 obj = base.CreateEntity(fields, parentEntity); return obj as ICustomModule1; } } public class CustomModule1Procedures : Cartella.Classes.FolioItemProcedures { public CustomModule1Procedures(Cartella.Classes.MSSQLUserSpecificDataProceduresBase procBase) : base(procBase) { } public override System.Type BaseObjectType { get { return TypeFinder.GetType("Cartella.Classes.CustomModule1"); } } } } namespace Cartella.Interfaces { using System; using Cartella.Classes; public interface ICustomModule1 : Cartella.Interfaces.IFolioItem { string Field1 { get; set; } //------------------------------------------------------------------------------ // Add new property here: //------------------------------------------------------------------------------ string Field2 { get; set; } } public interface ICustomModule1Manager : IFolioItemManager<CustomModule1> { //------------------------------------------------------------------------------ // Edit the following line to include the new property: // ICustomModule1 CreateCustomModule1(string name, string description, string Field1, Cartella.Interfaces.IEntity parentEntity); //------------------------------------------------------------------------------ ICustomModule1 CreateCustomModule1(string name, string description, string Field1, string Field2, Cartella.Interfaces.IEntity parentEntity); } }
- Save changes and exit editor.