Monday, November 30, 2009

Displaying thumbnail using DataViewerWebPart

Displaying thumbnail using dataview webpart may tweaking In order to display thumbnails from a picture library.

You may receive XML errors if you try to do following steps
1. Drop listview webpart for picture library showing thumbnail and name of image
2. Right click and convert it to DataViewWebpart

So you may probably need to do following to resolve it.
1. Drop list view webpart and change its view to show name and url of image.
2. edit your file and replace XSL for displaying URL with following code to display thumbnail.
There is a limitation in a code that it will not be able to diplay thumbnail if you repeat file extension in your file name. So if your file name is like name.gif.gif it will not be able to display its thumbnail.

<img border="0" src="{concat('/',@FileDirRef,'/_t/',
substring-before(translate(@FileLeafRef,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz'),concat('.',@FileType)),'_',@FileType,'.','jpg')}"
alt="'{@FileRef}'"/>

Sunday, November 29, 2009

Write custom workflow for content approval

In order to write custom workflow for content approval you may need to do a lot depending on your requirements but following are few useful tips that may help you to to it quickly

1. How to approve list item from your code

In order to approve list item from your code you need to need to modify list item's moderation status using following line
Item.ModerationInformation.Status = SPModerationStatusType.Approved
Where Item is your list item

2. In order to start workflow automatically on item publishing event
You need to select following option while associating custom workflow with your list
"Start this workflow to approve publishing a major version of an item"
You may not find this option with your custom work flow if you haven't placed following configuration in your wokflow meta data while defining work flow.

<Workflow .... .> .......... <MetaData> <InitiationType>
Manual;#OnNewItem;#OnItemUpdate;#OnMajorCheckIn

</
InitiationType> </MetaData> </Workflow>

Friday, November 27, 2009

General correlation token related issues with CreateTaskWithContentType

You may encounter different issues while working with windows workflow foundation if you have not initialize you correlation token correctly or not configured you activity properly.

When you enable tracing or start debugging your workflow you may get following.

CorrelationToken Uninitialized for {corelationtokenname} owner activity {Task Name}

following configuration needs to be checked in order to rectify above issue.

1. Check "Correlation Token.Owner Activity" is set to current state
CreateTaskWithContentType should not run with shared workflow correlation token. You should define separate correlation token for all task activities. The owner of defined correlation token should be your activity.

2. Check all related activities e.g. OnTaskChange etc has same correlation token
When you utilize CreateTaskWithContentType activity you may need to place few more activities e.g. OnTaskChange, CompleteTask etc. Activities related to CreateTaskWithContentType activity should have same correlation token assigned.

3. Check that content type is added (enabled) in your task list
When you use CreateTaskWithContentType with custom content type you may get this issue if content type is not added in your task list. In this case you will have to add your content type in your task list using following steps
- Go to list setting screen of your task list
- Allow management of content type from advance setting link
- Add your custom content type in task list

Tuesday, November 17, 2009

Sharepoint : How to set content approval status programatically

There are business scenarios when we need to programmatically set content pusblishing status of an Item. Examples would be the custom workflow for publishing or content approval. Following simple line of code can be used to set approval status.


item.ModerationInformation.Status = SPModerationStatusType.Approved;
item.Update();

Sunday, November 15, 2009

How to query data from multiple sharepoint lists

Share point provide two mechanism for querying data from multiple share point lists

  1. SPSiteDataQuery
  2. FullTextQuery

Following link on msdn explain usage for SPSiteDataQuery
http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spsitedataquery.aspx

Friday, November 13, 2009

Installing Sharepoint Server on Windows 2008

Windows 2008 does not support installation of Share point Server 2007 without Office/WSS Service pack 1. Therefore when you try to install share point setup on Windows 2008 machine it will give you an error that service pack is required to run this installation.
In order to run installation on windows 2008 machine you need to perform following set of activities.

First download WSS Service Pack 1 and Office Sharepoint Server 2007 Service Pak 1 from Microsoft site.

Copy all files from installation CD to local disk.

Open command prompt and navigate to folder where you have downloaded service pack1 for WSS and Office server and run following commands
wssv3sp1-kb936988-x86-fullfile-en-us.exe /extract:C:\WSSSP1
officeserver2007sp1-kb936984-x86-fullfile-en-us.exe /extract:C:\MOSSSP1

Copy all files you extracted in last step i.e. C:\WSSP1 and C:\MOSSSP1 to Updates folder of Sharepoint installation (at local disk)

Now run sharepoint setup from your installation files in your hardisk. It should run properly.

Basically Windows 2008 require you to install Sharepoint setup file with SP1. Sharepoint setup looks in updates folder and applys those updates with installation so as we copied extracted files of SP1 in updates folder of shrepoint setup it will automatically deploy those files and will not give any error.

Wednesday, November 11, 2009

Using SQL Reporting Services with in Microsoft Sharepoint in native Mode

If you need to display Reports developed using SQL Reporting services there
are two options. Either you use you Share point Server in integrated mode with
SQL Server Reporting services or you may use it in Native Mode. Following
defines the steps you need to perform in oder to use reports in Native Mode.

Microsoft provide report explorer and report viewer web part to display and
browse reports deployed at MS SQL Server Reporting Server. But these web parts
are not installed by default so you need to download and install reporting
server add on (SharePointRS.msi) following link may be used for
downloading SQL Server Add-on from Microsoft site.

http://www.microsoft.com/downloads/details.aspx?familyid=1E53F882-0C16-4847-B331-132274AE8C84&displaylang=en

Now even if you installed the addon it will deploy necessary cab files in your
system but web part will not be activated automatically and you need to run
following stsadm command in order to activate and utilize web parts

"%SystemDrive%\Program Files\Common Files\Microsoft Shared\web server
extensions\12\bin\stsadm.exe" -o addwppack -globalinstall -force -filename
"C:\Program Files\Microsoft SQL Server\90\Tools\Reporting
Services\SharePoint\RSWebParts.cab"

After running above command reporting server web part will be
available in miscellaneous group.

Monday, November 9, 2009

Favourite Quotes

  • The best way to predict the future is to invent it.
  • Make everything as simple as possible, but not simpler. -- Albert Einstein
  • Any fool can make things bigger, more complex, and more violent. It takes a touch of genius and a lot of courage to move in the opposite direction. -- Albert Einstein
  • Only two things are infinite, the universe and human stupidity, and I'm not sure about the former. -- Albert Einstein
  • Trust yourself. You know more than you think you do. -- Benjamin Spock

Monday, November 2, 2009

Sharepoint - How to design printer friendly pages

I was thinking about adding support for printing my content pages in my share point site. As I have done this before in my custom side so I utilize same idea for hiding content displayed in my master page in print view. I created a css file and published in my style library and add css link in my master page with media set to print

<link href="[cssfilelink]" rel="stylesheet" type="text/css" media="print" /&gt

Then I added following 4 css classes in my stylesheet. After finishing this when I print my sharepoint page from browser it autmatically removed master page section and print only content area.

.ms-globalbreadcrumb
{
display:none;
}

.ms-globalTitleArea
{
display:none;
}

.ms-bannerContainer
{
display:none;
}

.ms-navframe
{
display:none;
}

Any suggestion or better strategies for achieving above is welcome

SQL Server 2005 Reporting Services using Visual Studio 2008

Reports for SQL Server reporting services requires Visual Studio 2005 on your machine. So even if you have Visual Studio 2005 you will need to install Visual Studio 2005 for development of your SQL Server 2005 Reports.

ref: http://social.msdn.microsoft.com/forums/en-US/sqlreportingservices/thread/9a7a78a0-bf5c-458a-9cb0-bc82004501f7/