Get sharepoint Forum address

Source: Internet
Author: User

Previously, after creating a discussion board, you need to access the details of the discussion in another site, so you can find the address of the discussion topic. The following is the method in use.
Through event listening (for the creation of listening events, refer to the MSDN example), after the discussion board is created, obtain its address. Currently there is manual splicing. If there is a better method, please note it;

Create a discussion board named text. The address is as follows:
Http: // win-l8muo3ci7hb/sites/Project/Lists/List4/Flat. aspx?
RootFolder = % 2 Fsites % 2 FProject % 2 FLists % 2FList4% 2 Ftest &
FolderCTID = 0x012002000011AC68D38FA24BAE274F76B33E6338

Where,
RootFolder parameter: After URL transcoding, the result of anti-transcoding is
RootFolder =/sites/Project/Lists/List4/test
It is to discuss the list address + topic.
FolderCTID parameter: After the trial is deleted, you can access the discussion board and cannot find its meaning, so it is not added.

/// <Summary>
/// An item was added.
/// </Summary>
Public override void ItemAdded (SPItemEventProperties properties)
{
Base. ItemAdded (properties );
If (properties. ListTitle = "Project Discussion ")
{
Try
{
Using (SPWeb web = properties. OpenWeb ())
{
String userName = web. CurrentUser. Name;
String projectName = web. Title;
String projectUrl = web. Url;
SPList list = web. Lists [properties. ListId];
String title = list. Fields. GetField ("topic"). InternalName;
String titleValue = properties. ListItem [title]. ToString ();
// Obtain the Topic link
// Properties. List. DefaultDisplayFormUrl is the default address of the displayed list. You can find the list address of the discussion board;
String tmpUrl = properties. List. DefaultDisplayFormUrl. Substring (0, properties. List. defadisplaydisplayformurl. LastIndexOf ('/'));
String RootFolder = tmpUrl + "/" + titleValue;
// Url transcoding to avoid address errors when Chinese characters are included
RootFolder = System. Web. HttpUtility. UrlEncode (RootFolder );
String discussionUrl = "http: //" + Environment. MachineName + tmpUrl + "/Flat. aspx? RootFolder = "+ RootFolder;
}
}
Catch (Exception ex)
{
}
}
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.