Sunday, January 16, 2011

SharePoint 2010 Products Configuration Wizard - Text Error

This is not a big deal! I found a text error (missing white space) in SharePoint 2010 Products Configuration Wizard Smile

SharePointWizardErrorCaption

Saturday, January 15, 2011

My Useful SharePoint 2010 Resources

Understanding the Basics of Collaboration in SharePoint 2010

Understanding the Architecture of SharePoint 2010

Optimizing SQL Server for a SharePoint 2010 Implementation

Installing SharePoint 2010

Using Windows PowerShell to Perform and Automate Farm Administrative Tasks

Organizing Information

Collaboration and Portals

Search Server 2010 and FAST Search: Architecture and Administration

Using Windows PowerShell to Manage Search Services and FAST Search

Customizing the Search Results and Search Center

Administering Web Content Management and Publishing

Securing Information

Aggregating External Data Sources

Web Parts and Their Functionality in SharePoint 2010

Publishing SharePoint 2010 to Mobile Devices

Business Intelligence, Reporting Services, and PerformancePoint Services

Upgrading to SharePoint 2010

Sunday, January 9, 2011

PowerShell for SharePoint

First things first. Where can we find PowerShell? When running on a SharePoint server, two possibilities exist: either select the SharePoint 2010 Management Shell from the Start menu or open a command prompt and enter the following:

PowerShell

If we’re using the SharePoint management shell, the SharePoint snap-in will already be installed. If we’re using a standard PowerShell console, we can install the snap-in by entering the following command:

Add-PSSnapIn Microsoft.SharePoint.PowerShell

We can check the list of installed snap-ins by using this command:

Get-PSSnapIn

 

Connecting to SharePoint Remotely

We can open a PowerShell session on a client machine and then use remoting to connect to a SharePoint server. To enable remoting on the server, enter the following command:

Enable-PSRemoting
 
This command will enable the WinRM service and set up the firewall to allow incoming sessions. Now, we can connect from any client machine by entering the following command:
 
Enter-PSSession "Server Name" -Credential (Get-Credential)
 

PowerShell Permissions

 
To use SharePoint cmdlets, a user must be a member of the SharePoint_Shell_Access role for the farm configuration database as well as a member of the WSS_ADMIN_WPG group on the SharePoint front-end server. To grant users the appropriate permissions, use the
following command:
 

Add-SPShellAdmin -Username domain\username -database (Get-SPContentDatabase-webapplication http://weburl)

 

Working with Site Collections and Sites

 
Most of the cmdlets commonly used in the management of site collections or sites end in SPSite or SPWeb. To pick up a reference to a site collection, we can use the following:
$site=Get-SPSite -Identity http://siteurl
 
Or we can return a list of all site collections by using this:
 
Get-SPSite

When it comes to managing site objects (SPWeb), we can pick up a specific web site using this:
 
Get-SPWeb -Site http://SiteUrl

or

Get-SPWeb -Site $site

 

Creating Site Collections and Sites

Create a new site collection using the New-SPSite cmdlet:

New-SPSite -Url http://localhost/Sites/NewSiteCollection - OwnerAlias username

Add new sites using the New-SPWeb cmdlet: 


Deleting Site Collections and Sites


We can delete site collections and sites by using the Remove-SPSite or the Remove-SPWeb cmdlet.


or


Setting Properties on SharePoint Objects


$web=SP-GetSPWeb -Identity http://myweburl
$web.Title="My New Title"
$web.Update()

 

Working with Lists and Libraries

Enumerate the lists on a site using the following:

Get-SPWeb -Identity http://myweburl | Select -Expand lists| Select Title

Add new lists using the Add method of the Lists property:

Get-SPWeb -Identity http://myweburl | ForEach {$_.Lists.Add("My Task List", "",$_.ListTemplates["Tasks"])}


Working with Content


Retrieve a list of all items in a site using the following:

Get-SPWeb -Identity http://myweburl | Select -Expand Lists | Select -Expand Items | select Name, Url

Apply a filter to show only documents:

Get-SPWeb -Identity http://myweburl | Select -Expand Lists | Where {$_.BaseType -eq "DocumentLibrary"} | Select -Expand Items | select Name, Url

Use of filters to search for a specific item:

Get-SPWeb -Identity http://myweburl | Select -Expand Lists | Select -Expand Items | Where {$_.Name -like "foo*"} | select Name, Url


Creating New Documents

To create a new document in a document library, use the following:

function New-SPFile($WebUrl, $ListName, $DocumentName,$Content)
{
$stream = new-object System.IO.MemoryStream
$writer = new-object System.IO.StreamWriter($stream)
$writer.Write($content)
$writer.Flush()
$list=(Get-SPWeb $WebUrl).Lists.TryGetList($ListName)
$file=$list.RootFolder.Files.Add($DocumentName, $stream,$true)
$file.Update()
}
New-SPFile -WebUrl "http://myweburl" -ListName "Shared Documents" -DocumentName "PowerShellDocument.txt" -Content "Document Content"

 

Working with Timer Jobs

Get a list of all timer jobs:

Get-SPTimerJob

Or we can get a list of job failures grouped by the job name:

Get-SPTimerJob | Select -Expand HistoryEntries | Where {$_.Status -ne "Succeeded"} | group JobDefinitionTitle

Saturday, January 8, 2011

Renaming The Central Administration Database

Unless you perform a command-line installation, by default SharePoint Central Administration site uses database name with a Globally Unique Identifier (GUID), for example: SharePoint_AdminContent_<GUID>. If you like to rename the Central Administration Database, you can follow these steps but with extreme caution Winking smile:

  • Log on to your SQL Server with an account that has full access; ideally, you should use the same account that you used for your SharePoint installation.
  • Open the SQL Server Management Studio interface and locate the SQL Server instance that contains your Central Administration database, for example: SharePoint_AdminContent_<GUID>. Right-click the database name and choose the Rename command from the shortcut menu to enter edit mode. Then press Ctrl+C to copy the existing name of the database for later use.
  • Back up the existing SharePoint_AdminContent_<GUID> database by right-clicking the name of the database and then selecting the Tasks command.
  • When you have successfully backed up the database, restore the information from the backup that you just performed to a new database having a user-friendly database name such as CentralAdmin_Content_SharePointMalayaDB.
  • Open SharePoint Central Administration. Under Application Management, click Manage Content Databases.
    • Select the SharePoint Central Administration v4 Web application using the Web application drop-down list.
    • Click the old database name, SharePoint_AdminContent_<GUID>.
    • Use the Database status drop-down option to change the status from Ready to Offline.
    • Do not select the option to remove the content database.
    • Click OK.
  • Log on to the SharePoint server using the account that was used to provision the database. Usually this is the service user account that you configured SharePoint with when you provisioned the content databases during the installation of SharePoint 2010.
  • After opening the command prompt, perform the following steps.
    • Type cd C:\Program Files\Common Files\Microsoft Shared\Web server extensions\14\BIN\ to change the directory to the SharePoint 2010 root so you can run the STSADM commands.
    • Delete the original Central Administration database, the one with the GUID that you copied earlier, using the following command:

      stsadm -o deletecontentdb -url http://UrlOfYourCentralAdministration:portnumber –databasename SharePoint_AdminContent_<GUID> -databaseserver NamedInstanceOfYourSqlServer

    • Associate the newly created database with your Central Administration using the following STSADM command:

      stsadm -o addcontentdb -url http:// UrlOfYourCentralAdministration:portnumber -databasename SharePoint_AdminContent_SharePointMalayaDB -databaseserver NamedInstanceOfYourSqlServer

  • Return to SharePoint Central Administration. Under Application Management, click Manage Content Databases and refresh the page to verify that your Central Administration database reflects the new database name.
  • If you see a database with the SharePoint_AdminContent_SharePointMalayaDB name, you can then be sure that the original Central Administration database is backed up, and you can delete it from SQL Server.

CentralAdministrationDBRename

Tuesday, January 4, 2011

Write Error Logging Entries To The SharePoint Unified Logging Service (ULS) Logs

All SharePoint exceptions are derived from the SPException class. We can write error logging entries to the SharePoint Unified Logging Service (ULS) logs by using code similar to the following sample:

using Microsoft.SharePoint.Administration;
 

try
{
    // Some code
}
catch (Exception ex)
{
    // Create diagnostics category
    SPDiagnosticsCategory oCat = new SPDiagnosticsCategory("A new category", TraceSeverity.Monitorable, EventSeverity.Error);
    // Write to ULS
    SPDiagnosticsService.Local.WriteEvent(1, oCat, EventSeverity.Error, "Error custom message", ex.StackTrace);
}

ULS is stored in the file system in “C:\Program Files\Common Files\Microsoft Shared\web server extensions\14\LOGS”.

Sunday, December 26, 2010

Default SharePoint 2010 Application Pools

When you configure SharePoint using the post-installation Farm Configuration Wizard, you will notice that the system comes preconfigured with five separate application pools. These application pools that are configured by the wizard, as well as the security context under which each pool runs is shown in table below:

Application Pool

Description

Identity

SharePoint Central Administration v4

SharePoint Central Administration v4

Farm Administrator Account

SharePoint Web Services System

SharePoint Topology Service Application

Farm Administrator Account

SecurityTokenServiceApplicationPool

SharePoint Security Token Service Application

Farm Administrator Account

SharePoint Web Services Root

SharePoint Service Applications

Service Account
SharePoint – 80

Default preconfigured Content Application

Service Account

Monday, December 13, 2010

Ghosting/Unghosting Or Uncustomized/Customized Or Attached/Detached

With each new version of SharePoint comes another set of terms for this phenomenon. SharePoint 2003 brought us ghosting/unghosting; SharePoint 2007 scrapped these terms in favor of the more descriptive uncustomized/customized. Now with SharePoint 2010, the terms
attached and detached are used to prevent any ambiguity. In most SharePoint documentation, the terms ghosted/unghosted are still in use.

SharePoint 2003 Ghosting/Unghosting
SharePoint 2007 Uncustomized/Customized
SharePoint 2010 Attached/Detached

Friday, November 12, 2010

Deleting Data Using Silverlight and Javascript Client Object Model

Silverlight

private void Delete_Click(object sender, RoutedEventArgs e)
{
    ClientContext ctx = new ClientContext("Your Server Here");
    CamlQuery query = new CamlQuery();
    query.ViewXml = "<View><Query><OrderBy><FieldRef Name=\"Editor\" Ascending=\"False\" /></OrderBy></Query></View>";
    List announcements = ctx.Web.Lists.GetByTitle("Announcements");

    ListItemCollection listItems = announcements.GetItems(query);
    ctx.Load(listItems);
    ctx.ExecuteQueryAsync((s, args) =>
    {
        ListItem lastItem = listItems[listItems.Count - 1];
        lastItem.DeleteObject();
        announcements.Update();
        ctx.ExecuteQueryAsync((s1, args1) =>
        {
            Dispatcher.BeginInvoke(() =>
            {
                label1.Content = "Last record deleted";
            });
        }, null);
    }, (s, args) =>
    {
        Dispatcher.BeginInvoke(() =>
        {
            label1.Content = args.Message;
        });
    });
}

Javascript

function Delete_Click() {
    var ctx = new SP.ClientContext.get_current();
    var query = new SP.CamlQuery();
    query.viewXml = "<View><Query><OrderBy><FieldRef Name=\"Editor\" Ascending=\"False\" /></OrderBy></Query></View>";
    var announcements = ctx.get_web().get_lists().getByTitle("Announcements");
    var listItems = announcements.getItems(query);

    ctx.load(listItems, "Include(Title)");
    ctx.executeQueryAsync(function (s, args) {
        var lastItem = listItems.get_item(listItems.get_count() - 1);
        lastItem.deleteObject();
        announcements.update();
        ctx.executeQueryAsync(function (s, args) {
            var console = document.getElementById('DemoConsole');
            console.innerHTML = " Last Item Deleted";
        }, null);
    }, null);
}

For more information on Silverlight and JavaScript Client Object Model, see below:

Thursday, November 11, 2010

Updating Data Using Silverlight and Javascript Client Object Model

Silverlight

private void Update_Click(object sender, RoutedEventArgs e)
{
    ClientContext ctx = new ClientContext("Your Server Here");
    CamlQuery query = new CamlQuery();
    query.ViewXml = "<View><Query><OrderBy><FieldRef Name=\"Editor\" Ascending=\"False\" /></OrderBy></Query></View>";
    List announcements = ctx.Web.Lists.GetByTitle("Announcements");

    ListItemCollection listItems = announcements.GetItems(query);
    ctx.Load(listItems);
    ctx.ExecuteQueryAsync((s, args) =>
    {
        foreach (var item in listItems)
        {
            item["Title"] = "Updated";
            item.Update();
        }
        ctx.ExecuteQueryAsync((s1, args1) =>
        {
            Dispatcher.BeginInvoke(() =>
            {
                label1.Content = "Records Updated";
            });
        }, null);
    }, (s, args) =>
    {
        Dispatcher.BeginInvoke(() =>
        {
            label1.Content = args.Message;
        });
    });
}

Javascript

function Update_Click() {
    var ctx = new SP.ClientContext.get_current();
    var query = new SP.CamlQuery();
    query.viewXml = "<View><Query><OrderBy><FieldRef Name=\"Editor\" Ascending=\"False\" /></OrderBy></Query></View>";
    var announcements = ctx.get_web().get_lists().getByTitle("Announcements");
    var listItems = announcements.getItems(query);

    ctx.load(listItems, "Include(Title)");
    ctx.executeQueryAsync(function (s, args) {
        var itemEnum = listItems.getEnumerator();
        while (itemEnum.moveNext()) {
            var item = itemEnum.get_current();
            item.set_item("Title", "JavaScript Update");
            item.update();
        }
        ctx.executeQueryAsync(function (s, args) {
            var console = document.getElementById('DemoConsole');
            console.innerHTML = "JavaScript Update Completed";
        }, null);
    }, null);
}

For more information on Silverlight and JavaScript Client Object Model, see below:

Adding Data Using Silverlight and Javascript Client Object Model

Silverlight

private void Add_Click(object sender, RoutedEventArgs e)
{
    ClientContext ctx = new ClientContext("Your Server Here");
    List announcements = ctx.Web.Lists.GetByTitle("Announcements");

    ListItemCreationInformation createInfo = new ListItemCreationInformation();
    ListItem newItem = announcements.AddItem(createInfo);
    newItem["Title"] = "A new item";
    newItem.Update();
    ctx.ExecuteQueryAsync((s, args) =>
    {
        Dispatcher.BeginInvoke(() =>
        {
            label1.Content = "Item Added";
        });
    }, (s, args) =>
    {
        Dispatcher.BeginInvoke(() =>
        {
            label1.Content = args.Message;
        });
    });
}

Javascript

function Add_Click() {
    var ctx = new SP.ClientContext.get_current();
    var announcements = ctx.get_web().get_lists().getByTitle("Announcements");

    var createInfo = new SP.ListItemCreationInformation();
    var newItem = announcements.addItem(createInfo);
    newItem.set_item("Title", "A new javascript item");
    newItem.update();

    ctx.executeQueryAsync(function (s, args) {
        var console = document.getElementById("DemoConsole");
        console.innerHTML = "Add Completed";
    }, null);
}

For more information on Silverlight and JavaScript Client Object Model, see below:

Wednesday, November 10, 2010

Retrieving Data Using Silverlight and JavaScript Client Object Model

Sliverlight

private void CAMLQuery_Click(object sender, RoutedEventArgs e)
{
    ClientContext ctx = new ClientContext("Your site here");
    CamlQuery query = new CamlQuery();
    query.ViewXml = "<View><Query><OrderBy><FieldRef Name=\"Editor\" Ascending=\"False\" /></OrderBy></Query></View>";

    List announcements = ctx.Web.Lists.GetByTitle("Announcements");
    FieldCollection fields = announcements.Fields;
    ctx.Load(fields);

    ListItemCollection listItems = announcements.GetItems(query);
    ctx.Load(listItems);
    ctx.ExecuteQueryAsync((s, args) =>
    {
        Dispatcher.BeginInvoke(() =>
        {
            BuildTable(fields, listItems);
        });
    }, (s, args) =>
    {
        Dispatcher.BeginInvoke(() =>
        {
            label1.Content = args.Message;
        });
    });
}

JavaScript

function CAMLQuery_Click() {
    var ctx = new SP.ClientContext.get_current();
    var query = new SP.CamlQuery();
    query.viewXml = "<View><Query><OrderBy><FieldRef Name=\"Editor\" Ascending=\"False\" /></OrderBy></Query></View>";
    var announcements = ctx.get_web().get_lists().getByTitle("Announcements");
    var listItems = announcements.getItems(query);
    ctx.load(listItems);
    var fields = announcements.get_fields();
    ctx.load(fields);
    ctx.executeQueryAsync(function (s, args) {
        var console = document.getElementById('DemoConsole');
        console.innerHTML = buildTable(fields, listItems);
    }, null);
}

For more information on Silverlight and JavaScript Client Object Model, see below:

Monday, November 8, 2010

How To Referencing the JavaScript Client Object Model

The following are simple steps to show how you can hooks your SharePoint page with JavaScript Client Object Model:

  1. From the Site Actions menu, choose New Page. Name the new page JSClientObjectModelTest.
  2. From the Page tab in the ribbon, click Save.
  3. Also from the Page tab, click the arrow under the Edit button and select Edit In SharePoint Designer.
  4. In SharePoint Designer, from the Home tab on the ribbon, select Advanced Mode.
  5. In the Content control with the ID PlaceHolderAdditionalPageHead, add the following markup after the SharePoint:RssLink tag (on one line):

    <SharePoint:ScriptLink runat="server" Name="sp.js" Localizable="false" LoadAfterUI="true"/>


  6. Scroll to the bottom of the page, and before the WebPartPage:WebPartZone tag, add the following markup (on one line):

    <script type="text/javascript" src="../SilverlightControls/JScriptTest.js" ></script>
    <div id="DemoConsole"></div>


  7. Click the Save icon in the upper-left corner of the window to save the changes to SharePoint. Click Yes in the Site Definition Page Warning.

For more information on Silverlight and JavaScript Client Object Model, see below:

Saturday, April 3, 2010

30+ SharePoint Custom Actions Location and Sample

Hi all,

It’s been a while. Today I posted a new blog at CustomWare site.

If you are interested in finding a complete reference for custom actions locations, group IDs and sample screenshots, please check out these links:

Tuesday, September 1, 2009

JIRA 4 Beta 3 and SharePoint

Today I installed and configured JIRA 4 Beta 3 in my local PC to check if the product developed by us works as expected with the new version of JIRA 4 Beta 3 API Web Service.

Installation and setting up of JIRA 4 Beta 3 doesn't trouble me much, then I proceed with testing of our product abd it works perfectly without the need for code changes.

So I investigated further the Web Service Definition Language (WSDL) for JIRA 4 Beta 3 and compared to previous version of JIRA 3.13.4 and 3.13.5. It turned out there are total of 8 new methods that have been added with this new version of JIRA 4 Beta 3 API Web Service, these includes:

  1. deleteProjectAvatar ( )
  2. getIssuesFromJqlSearch ( )
  3. getProjectAvatar ( )
  4. getProjectAvatars ( )
  5. getResolutionDateById ( )
  6. getResolutionDateByKey ( )
  7. setNewProjectAvatar ( )
  8. setProjectAvatar ( )

In  JIRA 3.13.4 and 3.13.5, there are total of 100 methods exposed by JIRA API Web Service - based on my initial investigation, none of existing methods are deprecated or updated in JIRA 4 Beta 3 (Don't count on this, let wait until Atlassian release a final documentation on JIRA API Web Service)

Tuesday, August 4, 2009

Implementing Mouse Hover & Click Highlighting in Default List View

Brad has a great post on how to Hover (MouseOver) Highlight and Click to Stay Highlighted in a SharePoint List and the BEST thing he did mentioned my name (“a guy called Sukri”) – Thanks Brad.

Note:

The entire solution step by step with code segment can be found at CustomWare site: SharePoint - Customising List Default View - Implementing mousehover & click highlighting in Default List View