Skip to main content

Posts

Showing posts with the label custom columns

Key Performance Indicators - Add custom column to KPI list in SharePoint

Scenario You want to add custom column to your KPI list using, but don't want to do this in UI. Solution 1. Add your custom column to the Site Columns SPWeb web = ...; string name = "Mighty Column"; SPFieldType type = SPFieldType.Text; bool required = false; SPField field = null; string internalName = web.Fields.Add(name, type, required); field = web.Fields.GetFieldByInternalName(internalName); web.Update(); 2. Alternative 1 - Add the created column to one of the KPI List content types SPList list = null; string sListTitle = "Mighty KPI List"; try {     list = sweb.Lists[sListTitle]; } catch { } if (list != null) {     SPContentType ct = list.ContentTypes["Indicator using data in SharePoint list"];     // or Indicator using data in Excel workbook     // or Indicator using data in SQL Server 2005 Analysis Services     // or Indicator using manually entered information ...