ISharePointUtility.CreateNewDiscussion

Fore Syntax

CreateNewDiscussion(List: ISharePointList; Title: String): ISharePointListItem;

Fore.NET Syntax

None;

Parameters

List. List, in which a discussion is created.

Title. Title of discussion.

Description

The CreateNewDiscussion method creates a new discussion and returns its parameters.

Example

Executing the example requires the SharePoint site located at: http://test-sharepoint.

Sub UserProc;
Var
    Site: ISharePointSite;
    Web: ISharePointWeb;
    Lists: ISharePointLists;
    List: ISharePointList;
    ListItem: ISharePointListItem;
    FStream: IFileStream;
    i: integer;
    AttachUrl: String;
Begin
    Site := New SharePointSite.Create;
    Site.Url := "http://test-sharepoint";
    Site.UseDefaultCredentials := True;
    //Connect to site
    Web := Site.RootWeb;
    Lists := Web.Lists;
    For i := 0 To Lists.Count - 1 Do
        List := Lists.Item(i);
        //Search for list with discussions
        If List.Type = SharePointServerTemplateType.DiscussionBoard Then
            //Create a new discussion
            ListItem := SharePointUtility.CreateNewDiscussion(List, "Project 2012");
            FStream := New FileStream.Create("c:\Project2012\Photo.rar", FileOpenMode.ReadWrite, FileShare.DenyWrite);
            AttachUrl := ListItem.Attachments.AddStream("Photo", FStream);
            ListItem.FieldValue("Body") := Link to photos: <a href="" + AttachUrl + """>Photo</a>";
            ListItem.Update;
            Dispose FStream;
            Break;
        End If;
    End For;
End Sub UserProc;

On executing the example the connection to the SharePoint site is executed. A list with collective discussion is found and a new topic is created in it. The topic contains an attached file link to that is available in the discussion body.

See also:

ISharePointUtility