SharePoint List Creation

In the previous example we created new empty site. Let us add a new list in it.

Since signature of method Main is generated considering objects selected in all browser windows, clear all set flags before proceeding by clicking Clear All Checks on the toolbar.

In order to create list, we need site collection and list template. References to these objects can be obtained differently, but we will use the most simple way – just find them in the tree and flag them: list collection is located in property Lists, list template can be found and flagged by searching across the collection ListTemplates (to be specific, select template with property Type = Events).

List

After opening new script window, we will see the following programming code:

C#
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using MAPILab.SharePoint.Explorer.CodeForm;
using MAPILab.SharePoint.Explorer.Utilities.ScriptRunner;

public class Tester
{
    static void Main(
            Microsoft.SharePoint.SPListCollection lists1
            ,Microsoft.SharePoint.SPListTemplate microsoftSharePointS2
            ,MAPILab.SharePoint.Explorer.CodeForm.MLCodeForm thisForm
            ,MAPILab.SharePoint.Explorer.Utilities.ScriptRunner.MLBrowser browser
            )
    {
        // Output browser configuration
        //browser.Text = "Browser window";
        //browser.DisplayMode = MAPILab.SharePoint.Explorer.Utilities.ScriptRunner.DisplayMode.Expanded; 
               
        browser.ReturnValue = null; 
    }
}
Visual Basic
Imports System
Imports System.Collections.Generic
Imports System.Diagnostics
Imports System.Text
Imports MAPILab.SharePoint.Explorer.CodeForm
Imports MAPILab.SharePoint.Explorer.Utilities.ScriptRunner

Public Class Tester
    Shared Sub Main(ByVal lists1 As Microsoft.SharePoint.SPListCollection, 
                    ByVal microsoftSharePointS2 As Microsoft.SharePoint.SPListTemplate, 
                    ByVal thisForm As MAPILab.SharePoint.Explorer.CodeForm.MLCodeForm, 
                    ByVal browser As MAPILab.SharePoint.Explorer.Utilities.ScriptRunner.MLBrowser)
                
        ' Output browser configuration
        'browser.Text = "Browser window"
        'browser.DisplayMode = MAPILab.SharePoint.Explorer.Utilities.ScriptRunner.DisplayMode.Expanded
            
        browser.ReturnValue = Nothing
    End Sub
End Class


Let`s modify this code so that new list is created at execution. Reference to newly created list will be returned by method main for further investigation.
C#
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using MAPILab.SharePoint.Explorer.CodeForm;
using MAPILab.SharePoint.Explorer.Utilities.ScriptRunner;

public class Tester
{
    static void Main(
            Microsoft.SharePoint.SPListCollection lists1
            ,Microsoft.SharePoint.SPListTemplate microsoftSharePointS2
            ,MAPILab.SharePoint.Explorer.CodeForm.MLCodeForm thisForm
            ,MAPILab.SharePoint.Explorer.Utilities.ScriptRunner.MLBrowser browser
            )
    {
        System.Guid listId = lists1.Add("SampleList", "Sample description", microsoftSharePointS2); 
                
        // Output browser configuration
        //browser.Text = "Browser window";
        //browser.DisplayMode = MAPILab.SharePoint.Explorer.Utilities.ScriptRunner.DisplayMode.Expanded;
            
        browser.ReturnValue = lists1[listId];  
    }
}
Visual Basic
Imports System
Imports System.Collections.Generic
Imports System.Diagnostics
Imports System.Text
Imports MAPILab.SharePoint.Explorer.CodeForm
Imports MAPILab.SharePoint.Explorer.Utilities.ScriptRunner

Public Class Tester
    Shared Sub Main(ByVal lists1 As Microsoft.SharePoint.SPListCollection, 
                    ByVal microsoftSharePointS2 As Microsoft.SharePoint.SPListTemplate, 
                    ByVal thisForm As MAPILab.SharePoint.Explorer.CodeForm.MLCodeForm, 
                    ByVal browser As MAPILab.SharePoint.Explorer.Utilities.ScriptRunner.MLBrowser)
                
         Dim listId As System.Guid
         listId = lists1.Add("SampleList", "Sample description", microsoftSharePointS2)

         'Output browser configuration
         'browser.Text = "Browser window"
         'browser.DisplayMode = MAPILab.SharePoint.Explorer.Utilities.ScriptRunner.DisplayMode.Expanded
        
         browser.ReturnValue =lists1(listId)
    End Sub
End Class

New browser window with information about created list will be opened as a result of executing this script:

Sample list

Our valued customers

HarePoint products are recognized by thousands of companies

  • Time Warner Cable
  • Bank of Canada
  • Department of Finance and Administration, State of Arkansas
  • Kofax
  • Raytheon