Search This Blog

Friday, March 17, 2017

Discussion Board SharePoint 2010

PowerShell:



Discussion board is tricky to deal with. Discussion are folders and Messages are items inside folders (very simple explanation). Best way to migrate one Discussion from source to destination list is to recreate new Discussion on destination list and then to recreate all Messages inside it.

Add-PSSnapin Microsoft.SharePoint.PowerShell

$web = Get-SPWeb "http://TeamSite"
$sourceList = $web.GetList("http://TeamSite/Lists/source/")
$destinationList = $web.GetList("http://TeamSite/Lists/destination/")

#Get desired discussion by Name (or use some other identifier eg. ID)
$sourceDiscussion = $sourceList.Folders | Where-Object {$_.Name -eq "My cool subject"}

#Add new discussion to destination list
$destinationDiscussion = [Microsoft.SharePoint.Utilities.SPUtility]::CreateNewDiscussion($destinationList.Items, $sourceDiscussion.Title)
#Copy basic field values (you can copy some custom fields if needed)
$destinationDiscussion["Body"] = $sourceDiscussion["Body"]
$destinationDiscussion["Author"] = $sourceDiscussion["Author"]
$destinationDiscussion["Editor"] = $sourceDiscussion["Editor"]
$destinationDiscussion["Modified"] = $sourceDiscussion["Modified"]
$destinationDiscussion["Created"] = $sourceDiscussion["Created"]
#Add discussion
$destinationDiscussion.SystemUpdate($false)

#Get all discussion messages (maybe there is better way to get it but this works)
$caml='<Where><Eq><FieldRef Name="ParentFolderId" /><Value Type="Integer">{0}</Value></Eq></Where>' -f $sourceDiscussion.ID
$query = new-object Microsoft.SharePoint.SPQuery
$query.Query = $caml
$query.ViewAttributes = "Scope='Recursive'";
$sourceMessages = $sourceList.GetItems($query)

foreach ($sourceMessage in $sourceMessages) {
    #Add new message to discussion
    $destinationMessage = [Microsoft.SharePoint.Utilities.SPUtility]::CreateNewDiscussionReply($destinationDiscussion)
    #Copy basic field values (you can copy some custom fields if needed)
    $destinationMessage["Body"] = $sourceMessage["Body"]
    $destinationMessage["TrimmedBody"] = $sourceMessage["TrimmedBody"]
    $destinationMessage["Author"] = $sourceMessage["Author"]
    $destinationMessage["Editor"] = $sourceMessage["Editor"]
    $destinationMessage["Modified"] = $sourceMessage["Modified"]
    $destinationMessage["Created"] = $sourceMessage["Created"]
    #Add message
    $destinationMessage.SystemUpdate($false)
}


Monday, February 27, 2017

SharePoint 2010 - Out of box webparts

SharePoint 2010 - Out of box webparts

Out Of Box (OOB) Webparts
These are the basic in-built components in SharePoint for displaying and managing list data without the need of any custom development. Not all of them will be available depending upon the version of SharePoint installed.

List of OOB Webparts in SharePoint 2010
Following is the list of OOB webparts in SharePoint 2010 along with the category.

List and Libraries
Announcements – Use this list to track upcoming events, status updates or other team news
Calendar – Use the Calendar list to keep informed of upcoming meetings, deadlines, and other important events
Links - Use the Links list for links to Web pages that your team members will find interesting or useful
Shared Documents – Share a document with the team by adding it to this document library
Site Assets – Use this library to store files which are included on pages within this site, such as images on Wiki pages.
Site Pages – Use this library to create and store pages on this site
Tasks – Use the Tasks list to keep track of work that you or your team needs to complete
Team Discussions – Use the Team Discussion list to hold newsgroup-style discussions on topics relevant to your team

Business Data
Business Data Actions – Displays a list of actions from Business Data Connectivity
Business Data Connectivity Filter – Filters the contents of Web Parts using a list of values from the Business Data Connectivity
Business Data Item – Displays one item from a data source in Business Data Connectivity
Business Data Item Builder – Creates a Business Data item from parameters in the query string and provides it to other Web Parts
Business Data List – Displays a list of items from a data source in Business Data Connectivity
Business Data Related List – Displays a list of items related to one or more parent items from a data source in Business Data Connectivity
Chart Web Part – Helps you to visualize your data on SharePoint sites and portals
Excel Web Access – Use the Excel Web Access Web Part to interact with an Excel workbook as a Web page
Indicator Details – Displays the details of a single Status Indicator. Status Indicators display an important measure for an organization and may be obtained from other data sources including SharePoint lists, Excel workbooks, and SQL Server 2005 Analysis Services KPIs.
Status Lists – Shows a list of Status Indicators. Status Indicators display important measures for your organization, and show how your organization is performing with respect to your goals.
Visio Web Access – Enables viewing and refreshing of Visio Web Drawings

Content Rollup
Categories – Displays categories from the Site Directory
Content Query – Displays a dynamic view of content from your site
Relevant Documents – Displays documents that are relevant to the current user
RSS Viewer – Displays an RSS feed
Site Aggregator – Displays sites of your choice.
Sites In Category – Displays sites from the Site Directory within a specific category
Summary Links – Allows authors to create links that can be grouped and styled
Table Of Contents – Displays the navigation hierarchy of your site
Web Analytics web Part – Displays the most viewed content, most frequent search queries from a site, or most frequent search queries from a search center
WSRP Viewer – Displays portlets from web sites using WSRP 1.1
XML Viewer – Transforms XML data using XSL and shows the results

Filters
Choice Filter – Filters the contents of Web Parts using a list of values entered by the page author
Current User Filter – Filters the contents of Web Parts by using properties of the current user
Date Filter – Filter the contents of Web Parts by allowing users to enter or pick a date
Filter Actions – Use the Filter Actions Web Part when you have two or more filter Web Parts on one  Web Part Page, and you want to synchronize the display of the filter results
Page Field Filter – Filters the contents of Web Parts using information about the current page
Query String (URL) Filter – Filters the contents of Web Parts using values passed via the query string
SharePoint List Filter - Filters the contents of Web Parts by using a list of values
SQL Server Analysis Services Filter – Filters the contents of Web Parts using a list of values from SQL Server Analysis Services cubes
Text Filter – Filters the contents of Web Parts by allowing users to enter a text value

Forms
HTML Form Web Part – Connects simple form controls to other Web Parts
InfoPath Form Web Part – Use this Web Part to display an InfoPath browser-enabled form

Media and Content
Content Editor – Allows authors to enter rich text content
Image Viewer – Displays a specified image
Media Web Part – Use to embed media clips (video and audio) in a web page
Page Viewer - Displays another Web page on this Web page. The other Web page is presented in an IFrame
Picture Library Slideshow Web Part – Use to display a slideshow of images and photos from a picture library
Silverlight Web part – A web part to display a Silverlight application

Outlook Web App
My Calendar – Displays your calendar using Outlook Web Access for Microsoft Exchange Server 2003 or later
My Contacts – Displays your contacts using Outlook Web Access for Microsoft Exchange Server 2003 or later
My Inbox – Displays your inbox using Outlook Web Access for Microsoft Exchange Server 2003 or later
My Mail Folder – Displays your mail folder using Outlook Web Access for Microsoft Exchange Server 2000
My Tasks – Displays your tasks using Outlook Web Access for Microsoft Exchange Server 2003 or later

PerformancePoint
PerformancePoint Filter – This web part displays PerformancePoint filters. Filters may be linked to other web parts to provide an interactive dashboard experience. Filter types include lists and trees based on a variety of data sources
PerformancePoint Report – This web part displays PerformancePoint reports. Reports may be linked to other web parts to create an interactive dashboard experience. Report types include: Analytic charts & grids, Strategy Maps, Excel Services, Reporting Services, Predictive Trend charts, and web pages
PerformancePoint Scorecard – This web part displays a PerformancePoint scorecard. Scorecards may be linked to other web parts, such as filters and reports, to create an interactive dashboard experience.
PerformancePoint Stack Selector – This web part displays a PerformancePoint Stack Selector. All PerformancePoint web parts, such as filters and reports, contained in the same zone will be automatically stacked and selectable using this web part.

Search
Advanced Search Box – Displays parameterized search options based on properties and combinations of words.
Dual Chinese Search – Used to search Dual Chinese document and items at the same time.
Federated Results – Displays search results from a configured location
People Refinement Panel – This webpart helps the users to refine people search results
People Search Box – Presents a search box that allows users to search for people
People Search Core Results – Displays the people search results and the properties associated with them.
Refinement Panel – This webpart helps the users to refine search results
Related Queries – This webpart displays related queries to a user query
Search Action Link – Displays the search action links on the search results page
Search Best Bet – Displays high-confidence results on a search results page.
Search Box – Displays a search box that allows users to search for information.
Search Core Results – Displays the search results and the properties associated with them
Search Paging – Display links for navigating pages containing search results.
Search Statistics – Displays the search statistics such as the number of results shown on the current page, total number of results and time taken to perform the search.
Search Summary – Displays suggestions for current search query
Search Visual Best Bet – Displays Visual Best Bet
Top Federated Results – Displays the Top Federated result from the configured location

Social Collaboration
Contact Details – Displays details about a contact for this page or site.
Note Board – Enable users to leave short, publicly-viewable notes about this page.
Organization Browser – This Web Part displays each person in the reporting chain in an interactive view optimized for browsing organization charts.
Site Users – Use the Site Users Web Part to see a list of the site users and their online status.
Tag Cloud – Displays the most popular subjects being tagged inside your organization
User Tasks – Displays tasks that are assigned to the current user.
What’s New – This Web part shows new information from specified lists and libraries
Whereabouts – Use to display Whereabouts information.

Adding a OOB Webparts
For adding a OOB webpart to your SharePoint page you can follow the same steps mentioned in the "Adding a Webpart" section of 

Wednesday, November 23, 2016

PowerShell

http://stackoverflow.com/questions/6477693/c-sharp-how-to-list-scheduled-tasks-for-a-specific-user-with-the-taskschedular

http://www.codeproject.com/Articles/2407/A-New-Task-Scheduler-Class-Library-for-NET


https://pavanarya.wordpress.com/2012/01/08/scheduling-a-task-from-c/
https://forums.asp.net/t/1911217.aspx?can+any+one+explain+me+how+to+do+Windows+Scheduler+in+c+

https://msdn.microsoft.com/en-us/library/aa383607(v=vs.85).aspx (Microsoft Site)


Monday, November 16, 2015

Force Visual Studio to always run as an Administrator in Windows 7

Always start Visual Studio as an Administrator:

1. Right Click on Visual Studio icon
2. Go Properties
3. Under the Visual Studio 2012 Properties. Select "Advanced"
4. @ Privilege Level section Select the Check box "Run this program as an Administrator".


Thursday, October 8, 2015

Authencate username and password in SharePoint 2010 programatically


I used this method on a Windows Form Application and it works fine:

private bool loginSharePoint()
    {
        lbLoginStatus.Text = "Logging in Sharepoint server";

        bool isValid = false;

        //validating Sharepoint login
        string spUsername = tbSharePointUsername.Text;

        string spPassword = tbSharePointPassword.Text;


        pc = new PrincipalContext(ContextType.Domain, spUsername.Split('\\')[0]);

        pbLogin.PerformStep();
        // validate the credentials
        isValid = pc.ValidateCredentials(spUsername.Split('\\')[1], spPassword);
        if (isValid)
        {
            pbLogin.PerformStep();

            pbLogin.PerformStep();
            site = new SPSite(tbSharePointUrl.Text);

            pbLogin.PerformStep();
            web = site.OpenWeb();

            pbLogin.PerformStep();
            if (web.DoesUserHavePermissions(spUsername, SPBasePermissions.Open))
                isValid = true;
            else
                isValid = false;
        }


        return isValid;
    }

  string Url = txtSiteURL.Text.ToString();

                    SPSite spSite = new SPSite(Url);
                    PrincipalContext Context = new PrincipalContext(ContextType.Domain);
                    string oUser = txtDomain.Text.ToString() + "\\" + txtUsername.Text.ToString();
                    string oPassword = txtPassword.Text.ToString();
                    bool oVar;
                    using (Context)
                    {
                        oVar = Context.ValidateCredentials(oUser, oPassword);
                    }