Saturday, February 28, 2009

Site Aggregator Web Part of SharePoint

Site Aggregator is a simple and straight-forward web part, can be used to display sites (specific page in a site) of our choice.

The following are the important properties of Site Aggregator WebPart.

Properties of Site Aggregator

1. Number of characters before ellipses
Sets the number of characters that should be rendered in a tab before truncating and showing ellipses

Default value of this property is 30


2. Number of tabs to show before more dropdown
Sets the number of tabs that should be rendered before additional items are put in the more dropdown

Default value of this property is 5

3. URL
This URL fragment will be appended to the site URL when a tab is selected

Default value of this property is MyInfo.aspx (_layouts/MyInfo.aspx).

I have used “Site Content and Structure” page (_layouts/sitemanager.aspx) page. This will help managers to easily navigate and review “Pending Approvals” or other task of all sites from a same page.

Add the “Site Aggregator” to your page and set the Target Audience property to Managers or the respective approver group, so that only managers/approvers can see this web part.



Use “New Site Tab” from Sites menu to create a new Site Tab.



Set the URL property to “_layouts/sitemanager.aspx”. See the below image for the properties of Site Aggregator.



After adding all the sites, select the “Pending Approval” view to see all the approvals which are pending for the selected site.



Managers / Approvers can manage all approvals or view other details in same page.

Saturday, February 21, 2009

Customizing SharePoint Blog Posts Web Part

Description

The OOTB posts web part displays complete posts in Home Page (default.aspx) of Blog Site. In this post, the Posts web part is customized to display only 250 characters from each post and a “more” link to the actual blog post instead of displaying complete Blog post in Home Page.

Before Customization

The Posts “ListViewWebPart” displays complete posts in home page.



After Customization

See the below screen, after the customization of Posts Web Part using SharePoint Designer.



Approach

Below the approach followed to display 250 characters blog post summary.

1) Convert Posts web part to XSD Data View using SharePoint Designer (SPD)
2) customize the XSL to display 250 characters summary and a “more” link to the actual blog post
3) Create a new Web Part from Customized Post web part and use it in other blog site

The following explains in-detail about the approach.
Creating XSD Data View

Use SharePoint Designer to convert the default list view web part (Posts) to XSD Data View. Open the Blog’s Home Page in your SharePoint Designer. Once the page is opened Right Click the List View Posts web part and select “Convert to XSD Data View”. See the below screen.
Customizing the XSD Data View

The Body column of the Posts list holds the complete summary text. The DataFormWebPart generated by SPD points the list by using the ListID. ListID is nothing but the GUID, which will change server to server. so use ListName instead of ListID to use this web part in blog site of any server.

Parameters Generated by SPD

After Change



The “removeHtmlTags” template of XSL used to strip the HTML text from the summary text. See the below screens which shows the XSL customizations.

removeHtmlTags” Template Definition

Call “removeHtmlTags” for getting Pure Text

Replace the following section



by



Now the customizations have been done. Export posts web part and use it in other Blog sites by uploading it to Web Part Gallery.



Tuesday, February 17, 2009

Scheduling Periodic/Delayed SharePoint-STSADM Backup using Windows Task Scheduler

STSADM can be used effectively with Windows Task Scheduler to schedule periodic/delayed backups.

STSADM

STSADM is the powerful built-in command line tool to backup/restore a SharePoint server farm or web application or site collection or a database. This tool has very simple, faster and easy to use commands for backup/restore SharePoint data.

STSADM backup syntax

For site collection backup

stsadm -o backup
-url
-filename
[-overwrite]


For catastrophic backup

stsadm -o backup
-directory
-backupmethod
[-item]
[-percentage]
[-backupthreads]
[-showtree]
[-quiet]

Please refer the following to get more details about the backup syntax
http://technet.microsoft.com/en-us/library/cc263441.aspx



Locking Site

Backup process will take longer time for large site collections. If any changes made to the site collection during the backup process, the backup can become corrupted. The preferred approach would be locking the site collection using Setsitelock command of STSADM till the backup process complete. Once the backup process completes, reset the site collection to its default state.

Please refer the following for more information on Setsitelock
http://technet.microsoft.com/en-us/library/cc262811.aspx

To get the current access level of the site
stsadm -o getsitelock -url <URL of Site Collection>

To lock the site/changing the site to read-only.
stsadm -o setsitelock -url <URL of Site Collection> -lock readonly

The following steps needs to be done for scheduling a periodic/delayed backup.

Batch File

Create a batch file, use Notepad to enter the below script and save as “Backup_Script.bat”.
This script creates daily backup of a site collection. A new backup file will be created each day and the file name is auto generated concatenating the current system date.

The script does the following

1) Determine the lock status
2) Locks the site collection
3) Creates a file name using current date
4) Creates backup
5) Unlock the site collection



Backup Script

@echo off
@echo --------------------------------------------------------
@echo backing up site collection <URL of Site Collection>
@echo --------------------------------------------------------
cd \Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN
@echo locking site collection before the backup process starts
@echo off
stsadm -o getsitelock -url <URL of Site Collection>
stsadm -o setsitelock -url <URL of Site Collection> -lock readonly
@echo Site locked

@Echo Generating File Name using current date
@For /F "tokens=1,2,3 delims=/ " %%A in ('Date /t') do @(
Set Day=%%A
Set Month=%%B
Set Year=%%C
Set All=%%C%%B%%A
)

@echo off
stsadm -o backup -url <URL of Site Collection> -filename "C:\Backup\Backup_%All%.bak"
@echo backup completed
@echo off
stsadm -o setsitelock -url <URL of Site Collection> -lock none
@echo Site lock removed

Note: Replace “<URL of Site Collection>” with your site collection URL. Also I’ve used a folder named “C:\Backup” change it to your respective folder.Windows Scheduled Tasks

Create a new Windows Scheduled Task by navigating Start -> Control Panel -> Scheduled Tasks -> Add Scheduled Task. The following screen shows the Windows Scheduled Task Wizard.





Click the Browse button and select the backup batch file (Backup_Script.bat). Click on Next to schedule the backup. The screen below shows the available options for scheduling a task.






Select the convenient time to take the backup. It is better to choose low traffic hours for backing up a site.



Once the time schedule has been selected, click on Next and supply the credentials to run the task.




The account which is used for executing the task should have the Administrative permission. Click Finish to complete the wizard. Now a daily backup has been scheduled, the Task Scheduler will execute the batch file daily at specified time.