CreateNewDiscussion(List: ISharePointList; Title: String): ISharePointListItem;
None
List. List that according to which the discussion is created.
Title. Title of discussion.
The CreateNewDiscussion method creates a new discussion and returns its parameters.
Executing the example requires the SharePoint site located by the http://test-sharepoint address.
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;
//Connection to the site
Web := Site.RootWeb;
Lists := Web.Lists;
For i := 0 To Lists.Count - 1 Do
List := Lists.Item(i);
//Search for the list with discussions
If List.Type = SharePointServerTemplateType.DiscussionBoard Then
//Create 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") := Reference to photos: <a href="" + AttachUrl + """>Photo</a>";
ListItem.Update;
Dispose FStream;
Break;
End If;
End For;
End Sub UserProc;
On executing an example the connection to the SharePoint site is performed. List with collective discussion is to be found and a new topic is created in it. Topic contains an attached file reference to that is available in the descussion.
See also: