Skip to main content

Posts

Showing posts with the label create KPI list programmatically

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 ...

Key Performance Indicators - Create KPI List and indicator programmatically

Scenario We need to create KPI List and an Excel Workbook indicator programmatically. Solution 1. Create an Excel Workbook: 2. Upload that workbook to the document library on our Web site: 3. Add trusted location to Excel Services settings: 4. Create a project in Visual Studio which will do the following: SPListTemplate template = null; foreach (SPListTemplate t in sweb.ListTemplates) // sweb - SPWeb object that we initialized before { if (t.Type.ToString() == "432") // this way we can pickup the KPI List list template { template = t; break; } } Guid gG = Guid.Empty; SPList list = null; string sListTitle = "Mighty KPI List"; try { gG = sweb.Lists.Add(sListTitle, sListTitle, template); list = sweb.Lists[gG]; } catch { // exists list = sweb.Lists[sListTitle]; } // in our case we need Indicator using data in Excel workbook content type SPContentType ct = list.ContentTypes["Indicator using data in Excel workbook"]...