How to Get XML Data From a SharePoint List – The Easy Way

September 29, 2009

Ever wanted to view your Sharepoint list as an XML data like me?

I think that you will run into a situation where you want to pull data as an XML format out of your SharePoint list some day, and to be honest i’ve found alot of ways pulling out the data to be viewed as XML.

Here i want to share this simple way to do this using  the great functionality of a file called owssvr.dll. and as a brief on this dll, i can say that the owssvr.dll file serves as the backbone of the SharePoint function. This is because the owssvr.dll file is the module that runs the mechanism for ‘export to spreadsheet and open with access’ options on the list Actions menu of SharePoint

So to get started, Simply format the following string to form the request URL:

http://{yoursite}/_vti_bin/owssvr.dll?Cmd=Display&List={list GUID}&XMLDATA=TRUE

where:

  1. {yoursite} : is the url of your site, which could be the root site of any child site.
  2. {list GUID} : is the GUID of your list.

So as an example of this request URL would be 

http://www.microsoft.com/_vti_bin/owssvr.dll?Cmd=Display&List=729ECA77-58B6-4739-9F50-9AE05D1FADAC&XMLDATA=TRUE

And you will get the XML view something like this:

MOSSListtoXML

In addition to viewing a list using the Cmd=Display command in the URL request, you can also return all data for a SharePoint list, but based on a specific view from that list, by adding the &View={ViewGuid} to the URL request, like the following:

http://{yoursite}/_vti_bin/owssvr.dll?Cmd=Display&List={list GUID}&View={ViewGuid}&XMLDATA=TRUE

where: {ViewGuid} : is the GUID of the list view.

The response for a simple view looks like this:

MOSSListViewtoXML

Notes:

- To find the GUID for a list, just go to the Settings page for the list and copy it from the URL. (see below)

GetListGUID


What every SharePoint and EPM administrator needs to know about Alternate Access Mappings

September 17, 2009

Here is an amazing  3-Parts-series of mastering Alternate Access Mappings(AAM), which will clarify your vision managing Web application paths, ip addresses & DNS records, specially when dealing with SharePoint:


9 Free Icon Sets By VisualPharm

September 7, 2009

VisualPharm is sharing various sets of beautiful free icons that are offered in Windows, Mac & PNG formats.

Icon sets are themed differently from animals to office space or finance icons. And, a set named “Must Have Icons” which includes 59 icons is a nice fit to be used in web applications.

FreeIcons

All sets come in 7 popular sizes: 16*16px, 24*24px, 32*32px, 48*48px, 64*64px, 128*128px & 256*256px.

They are free to use in personal & commercial projects (a link back is required).


Add existing Content database to a Site collection using STSADM

August 25, 2009

Stsadm Addcontentdb

Scenario
- You have an old content database (mdf/ldf or a backup) that you want to use as a content database for a new site collection.
or
- You want to create a new site collection, and to use an already existing content database (that holds your old data) for this site collection.

Assumption
- At the back-end SQL server you have a content database (in this example i will name it WSS_Content_Web1) attached to the SQL server, that is not linked to any site collection yet.
or
-At the back-end SQL server you’ve created a new database (in this example i will name it WSS_Content_Web1) using SQL management studio and restored a backed-up content database to it, to be used as a content database for you new site collection.

Steps
I will refer to this content database as WSS_Content_Web1, and the site collection as http://www.xyz.com/Web1

 

What we are up to do is:

  1. Create a content database using Sharepoint central administration.
  2. Create site collection that will use this content db.
  3. delete this content db.
  4. use STSADM to link this newly created site collection to the existing content database (in this example i will name it WSS_Content_Web1) in the back-end SQL.

 

So let us start:

  1. Launch “SharePoint 3.0 Centeral Administration”, and under the category “SharePoint Web Application Management” Select “Web application list” then select the web application that will contain the site collection.
  2. Select content databases, and click to add a new content database, name it WSS_Content_test and click ok.
  3. Create a new site collection, name it Web1. (notice that the new site collection will be attached to the newly created content database (WSS_content_test).
  4. Go back to the link “content databases” and delete the content database you’ve created “WSS_Content_test”.
  5. Launch Command prompt (CMD) … Start > Run > cmd and hit enter.
  6. write the following command line:
    Stsadm –o addcontentdb –url http://www.xyz.com/Web1 –databasename WSS_Content_Web1
  7. press enter to execute the command.

Go and browse to your newly created site collection, and enjoy.

 

notes:

  1. The STSADM tool is usually located in the following path (C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\BIN).
  2. For details about using the command addcontentdb visit this article in TechNet Addcontentdb: Stsadm operation (Office SharePoint Server).

SharePoint 2010 … Get a Sneak Peek now!

August 8, 2009

MOSS2010

On their home page, Microsoft SharePoint Server 2007 is to announce the release of their new SharePoint 2010 Server.

Keep your eye on it, Microsoft SharePoint Server 2007 Website, and here you can take the sneak peek (Click Here)


Yet another way of writing code in SharePoint2007

August 7, 2009

Hi all;

Remember my post ”Publish Your .ASPX Page With Code Behind To SharePoint 2007“, here is a simpler way of creating no code behind aspx page in SharePoint2007.

Here we will go through 3 steps:

  1. Build a simple aspx page in Visual Studio 2005 (with no separate code file).
  2. Tweak the SharePoint Web application Web.config file to accept running codes.
  3. Copy the aspx code to a new aspx page in SharePoint.

So lets start:

Building the aspx page

  1. open up Visual Studio 2005 or 2008, and make a new web site name it whatever.
  2. add another aspx page to the web site, but here uncheck the checkbox titled “Place code in separate file“.
  3. open this aspx page, and switch to design view.
  4. drop a TextBox, name it txtHello, and drop a Button name it btnHello.
  5. double click the btnHello command button.
  6. in the btnHello_Click protected sub, write this simple line code
  7. txtHello.text = “Hello World”. run your web site to test if every thing works fine.

  

Modify the web.config file of the SharePoint Web application:

  1. Open your Web application web.config file (which is found in this path –> C:\inetpub\wwwroot\wss\VirtualDirectories\xxxx   , the xxxx is the port number of your web application but in most cases for the default website its 80).
  2. add the following lines to the web.config file, directly inside the <configuration<SharePoint> directive and save.

<SafeMode MaxControls=500 CallStack=false DirectFileDependencies=10 TotalFileDependencies=50 AllowPageLevelTrace=false>

 <PageParserPaths>

<PageParserPath VirtualPath=/* CompilationMode=Always AllowServerSideScript=true IncludeSubFolders=true ></PageParserPath>

</PageParserPaths>

</SafeMode>

here we are telling SharePoint to accept running codes from the root path including all sub folders by using “/*” , but i prefer that you create a folder in your site collection, naming it “Applications”, and put all aspx pages that contains code in it, then change the path in the VirtualPath=/*  to be VirtualPath=/Applications/* .

 

Finally, copy the code in this aspx page to a new aspx page in SharePoint using SharePoint Designer:

  1. Open SharePoint Designer 2007, create a new aspx page, back to your web site which you created in vb.net, open the aspx page that you’ve created and tested, switch to code view, select all (Ctrl+A) and Copy (ctrl+C) code, paste the code in the SharePoint aspx page.
  2. Save & Check-In the SharePoint aspx page, run and have fun.

SharePoint Server 2007 SP2 … Slipstream!

August 7, 2009

In the scenario of installing a fresh new SharePoint2007, its a good idea to install it once with all the updates & service packs available.

Here i will go through bundle every thing in one MOSS2007 installation folder, including MOSS2007 Setup, WSS v3 SP2, microsoft office sharepoint server2007 SP2 and the cumulative update (15 july 2009) for both WSS v3 and MOSS2007.

To get started, we will need the SharePoint 2007 installation media, the SP2 for both WSS and MOSS, and the latest Cumulative Updates for both WSS and MOSS. so here are the links for downloading SP2 & the latest CUs:

To begin make a folder named c:\MOSS2007, and copy the MOSS2007 installation files and folders into it. (the folder will look similar to the following pic)

MOSS2007

Notice that theres a folder called Updates , here we will extract the SP2s and CUs files. as follows:

  1. open up command propmt . start > run > cmd.
  2. extract the four files (SPs & UCs) by writing EXTRACT command as follows depending on the path of each one (i prefer to put them all in one folder in the C:\ root to narrow the extraction command statement):

c:\wssv3sp2-kb953338-x64-fullfile-en-us.exe /extract:c:\MOSS2007\updates

- c:\officeserver2007sp2-kb953334-x64-fullfile-en-us.exe /extract:c:\MOSS2007\updates

 - c:\wss-kb968850-fullfile-x64-glb.exe /extract:c:\MOSS2007\updates

- c:\office-kb968851-fullfile-x64-glb.exe /extract:c:\MOSS2007\updates

And after completing the extraction proccess for all files, you shall notice that the Updates folder will be filled with many msp files, also you will notice that there are two DLL files named svrsetup.dll and wsssetup.dll, you must delete the file wsssetup.dll because its causing a Setup Error (Language not supported by your system), and conflecting with the other file svrsetup.dll.

Now you are ready to install a complete fully updated MOSS2007.

Recommended installation sequence for updates

Also if you are making a separate Updates installation, like say you have MOSS already installed, and want to update to Service Packs 2 and cumulative updates, then Microsoft enforces the installation order of service packs, but does not enforce the installation order of packages or patches. You can install packages or patches in any order you want, so long as every server in your farm is updated to the same level when you are done. In addition, there is no requirement to install an update unless your servers are affected by the problem described in the KB article for the update.

Although Microsoft does not enforce the update installation sequence, we recommend that you install the post-RTM updates for Office SharePoint Server that you require in the following sequence:

  1. Service Pack 2 for Windows SharePoint Services 3.0 (KB 953338)
  2. Service Pack 2 for Office SharePoint Server 2007 (KB 953334)
  3. The June CU for Windows SharePoint Services 3.0 (KB 971538)
  4. The June CU for Office SharePoint Server 2007 (KB 971537)
Important Important:
Remember to run either the SharePoint Configuration Wizard or Psconfig.exe at the command prompt on every server in your farm to complete the update. You are not required to run the SharePoint Configuration Wizard or Psconfig between each step in the sequence. You can to wait until all updates are installed on a given server before you run the SharePoint Configuration Wizard or PSconfig.

10 new SharePoint Themes!

August 7, 2009

Microsoft has released 10 new themes for Sharepoint to make Sharepoint not look like Sharepoint!

You can download the package from here :

http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=0a87658f-20b8-4dcc-ad7a-09ad22641f3a#tm

 

And the good thing here is that they are packaged as a solution.

And here are the instructions

Download the installer Run the installer and accept the End User License Agreement Once installed locate the Ten Themes for SharePoint in the start menu You can view all the themes at once by choosing the AllThemesPreview.jpg Locate TenThemesForSharePoint_March2009.zip in the start menu Uncompress the ZIP file to obtain the ten theme projects Load one a selected project in Visual Studio 2008 Use VSeWSS to deploy the project to view the final theme

For those who need to download the new sharepoint themes as a single WSP visit this link:

10 SharePoint Theme WSP


How to shrink Huge SharePoint Content Database Log file?

August 1, 2009

After facing the problem of not being able to perform any action, like deleting, adding new list items, and after viewing WFE server application event viewer, i’ve figured out that my Back-end SQL server is out of space (the drive that holds the content databases and DB log files).

So after surfing microsoft’s website, i’ve found the best way to shrink the log file which was about 60 GB to be any size that i want (say 10 MB).

  1. open up SQL management studio.
  2. open a new query window.
  3. paste the following command lines:

USE WSS_Content_Web;
GO
-- Truncate the log by changing the database recovery model to SIMPLE.
ALTER DATABASE WSS_Content_Web
SET RECOVERY SIMPLE;
GO
-- Shrink the truncated log file to 10 MB.
DBCC SHRINKFILE (WSS_Content_Web_log, 10);
GO
-- Reset the database recovery model.
ALTER DATABASE WSS_Content_Web
SET RECOVERY FULL;
GO

 Execute (F5).


Publish Your .ASPX Page With Code Behind To SharePoint 2007

July 22, 2008

It was a headache for me to create a HelloWorld.ASPX page, that contains only one button that changing its text to “Hello World !” when clicked (Imagine!!), and deploy it in my SharePoint 2007 Site, so I’ve start surfing the internet looking for a help on this issue. And after testing many ways, here is my 100% working Step-by-Step example on how to write a simple Hello World ASPX Page with Code Behind File example inside SharePoint 2007.

(I’ll be using Visual Basic .Net language to accomplish this Example)

1. Create new web site: Open Micorosft Visual Studio 2005, and start a new WebSite & Name it any thing and save it any where you want.

By default a Default.aspx page will be created with a CodeFile named Default.aspx.vb. Add a Button from the toolbox to this Default.aspx (in the design mode) , i assume that you (as a .Net developer) know that when you’r using a CodeFile, an Attribute will be added in the page directive of the Default.aspx page, named CodeFile, as follows

<%@ Page Language=”VB” AutoEventWireup=”false” CodeFile=”Default.aspx.vb” Inherits=”_Default” %>

2. Writing Code: Double click on the Button1 control and add the following line of code 

                     Button1.Text = “Hello World”

So the CodeFile will be looking as follows :

Partial Class _Default

Inherits System.Web.UI.Page

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles  Button1.Click

Button1.Text = “Hello World”

End Sub

End Class

3. Modify the code file class & add namespace: Now we want to make some modification to this file, first add a Namespace and name it HelloWorld and change the name of the class (which is _Default) to be Test and make the class Partial Public Class, after these modifications, your code behind file should look like the following:

Namespace HelloWorld
    Partial Public Class Test
        Inherits System.Web.UI.Page
        Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles  Button1.Click
           
Button1.Text = Date.Now
        End Sub
    End Class
End Namespace

4.Modify the Default.aspx “inherites” attribute: Now beacause of these modifications, we must now open the Default.aspx page in code view, and modify the Inherits=”_Default” in the page directive (the first line of the page) to inherit from this new named class, so make it Inherits=”HelloWorld.Test”. now save your work and run the application, just to be sure that every thing is going well. click the button. the Button text shall state “Hello World”

 

  

5.Creating Strong Name Key : Now we must prepare a “Strong Name Key” for our application, this can be done using a tool named “SN.exe”, you could find it in the following path:

“C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin\sn.exe”

or you can run it from Start >> Programs >> Microsoft Visual Studio 2005 >> Visual Studio Tools >> Visual Studio 2005 Command Prompt

write the following command line : SN -k c:\MyKey.snk .

after this command runs it will create a MyKey.snk file in the C:\ root directory (as we write in the comman line).and amessage will appear stating “key pair written to c:\mykey.snk”.

6.Publishing the web site: Now you must publish our site to any folder in our machine, as follows:

a.    From solution explorer, point to your project, right click.

b.    Select Publish Web Site (as shown below)

c.    Now brows to the folder you wish to publish your site to. In my example I’ll name it MySitePublished to the C:\ root, so its path will be C:\MySitePublished.

d.    Enable “use a key file generated with the strong name tool” option.

e.    Check the “Mark assemblies with Allow Partially Trusted Caller Attribute APTCA”, (as shown below)

f.     In the “key file location:” box, browse to the file “c:\MyKey.snk” (that you’ve generated in step “5″) & click open.

g.    Finally click ok. Now the publish operation will start, and will take only a few seconds to complete.

 

Please note that after publishing your web site, a “.DLL” file is generated, holding a name starts wirh “App_Web_” followed by random generated letters, like “App_Web_fyrnh9gi.dll”, and stored in the bin folder of your publishing folder (in our case its C:\MySitePublished\bin).

7. Preparing Your SharePoint Site for the new comer: Open the SharePoint Designer, we will do the following major steps:

1-    Creating a new .ASPX page inside a new folder called “Applications”.

2-    Copying our generated .DLL file to the bin folder of the SharePoint site.

3-    Modify the Web.Config file of the SharePoint site.

 

So Let’s We Start

A.    In your SharePoint Designer open your web site, Create a folder in the root of your SharePoint site and name it for example “Applications”.

B.     Add a new .ASPX page into it naming it Hellowrold.aspx, go to the code view, and delete all code inside.

C.    Open a new instance of your Visual Studio 2005, and open the published web site (which is C:\MySitePublished), ignore the warning message by pressing “Yes”, and open the Default.aspx page in the “Source View” and copy all the code.

D.   Back to the SharePoint Designer paste the source code inside the Helloworld.aspx page, notice in the page directive, the inherits attribute is changed to  inherits=”HelloWorld.Test,” followed by the name of the .DLL file generated, in my case App_Web_cotcnlm3, so the full page directive is stating <%@ page language=”VB” autoeventwireup=”false” inherits=”HelloWorld.Test, App_Web_cotcnlm3″ %>.

E.    Go to the bin folder of the published website (which is C:\MySitePublished), and copy the .DLL file (in my case its App_Web_cotcnlm3.dll), and paste it into the bin folder of your SharePoint site, which can found in the following path:

“C:\ Inetpub\Wwwroot\wss\VirtualDirectories\port number\bin”

The port number is the port of the SharePoint Server Web Application

F.    Now open the “Web.Config” file of your SharePoint Web Application, which can found in the following path:

“C:\ Inetpub\Wwwroot\wss\VirtualDirectories\port number

The port number is the port of the SharePoint Server Web Application

G.   Navigate to the <SafeControls> directive and add the following line:

<SafeControl Assembly=App_Web_cotcnlm3 Namespace=HelloWorld TypeName=* Safe=True />

H.    Navigate to the <PageParserPaths> directive and add the following line:

<PageParserPath VirtualPath=/Applications/* CompilationMode=Always AllowServerSideScript=true IncludeSubFolders=true/>

I.     I think that you need to make iisreset, so go to start menu > run, and write the following command : IISRESET.

J.     Preview your HelloWorld.aspx page and have fun.