Quantcast
Nov 152010
 

A short one this time. It seems though that a lot of people using SharePoint Services are not aware of this though and it is actually quite easy.

 

Even though it is not an option in any of the forms, you can have links from the quick-launch or from the Links list and Web-Part open in a new browser window or Tab.

 

The trick is that in the URL Field, you have to add a little piece of JavaScript. here is an example:

 

If you’d like a link to http://www.Microsoft.com open in a new window or tab, write the following in the URL field:

 

javascript:void window.open("http://www.microsoft.com")

Technorati Tags:

 Posted by at 10:27  Tagged with:
Oct 222010
 

In SharePoint you cannot use the start date column in a calendar to filter entries. This is quite annoying, because a lot of times, you’d like to show entries between two dates.

 

There is a little work-around that you can use to enable this functionality:

 

  • Open your Calendar list settings

  • Add new column, and call it StartFilter (for example)

  • Select ”Calculated” as a the type of new column

  • In the Formula field insert:
    =[Start Time]

  • Select Date and Time as data type of new column

  • Make sure “Add to default view” checkbox is un-ticked

  • Save the new column

You should now be able to use the StartFilter column to filter your calendar list.

Technorati Tags:

 Posted by at 10:45  Tagged with:
Oct 192010
 

Many times I find myself struggling with date time values in SQL. I should know this by hart now, but… I don’t.

 

Mostly my problems lie in the fact that an SQL database stores a DateTime value, which I often need. However, most of the times I need to present that value as either just a date, or just a time value (reports, dashboards, etc)

 

Today from our local SQL Wiz, I got a mail with all the important SQL Date-Time conversions. I guess he got tired of me asking. Thanks Chris!

 

There are loads of options, and you could use convert or cast, depending on your requirements. For me most of the time, convert does the job.

 

Syntax for CONVERT:
CONVERT (data_type [ (length ) ] ,expression [ ,style ] )

 

Convert to Date:

 

–MM/DD/YYYY

SELECT CONVERT(char, GETDATE(), 101)

–YYYY.MM.DD

SELECT CONVERT(char, GETDATE(), 102)

–DD/MM/YYYY

SELECT CONVERT(char, GETDATE(), 103)

–DD.MM.YYYY

SELECT CONVERT(char, GETDATE(), 104)

–DD-MM-YYYY

SELECT CONVERT(char, GETDATE(), 105)

–DD MON YYYY

SELECT CONVERT(char, GETDATE(), 106)

– MON DD, YYYY

SELECT CONVERT(char, GETDATE(), 107)

–MM-DD-YYYY

SELECT CONVERT(char, GETDATE(), 110)

–YYYY/MM/DD

SELECT CONVERT(char, GETDATE(), 111)

–YYYYMMDD

SELECT CONVERT(char, GETDATE(), 112)

–YYYY-MM-DD

SELECT CONVERT(varchar(10), GETDATE(), 120)

 

Convert to Time:

 

–00:00

CONVERT(VARCHAR(8) , GETDATE() , 108) AS HourMinute,

–00:00:00

CONVERT(VARCHAR(5) , GETDATE() , 108) AS HourMinuteSecond

 

To give an example of how a query would look:

 

SELECT  convert(varchar, SUM(entryDuration2)/ 60) + ‘:’  + right(convert(char(3), 100 + SUM(entryDuration2)% 60), 2) AS Expr1 FROM TTentries WHERE (entryEndTime IS NOT NULL) AND (UserName = @UserName) AND (entryStartDate = CONVERT (VARCHAR(10), GETDATE(), 111))

Technorati Tags: ,

Oct 132010
 

The STSADM command is a very important one for anyone managing a SharePoint 2007 / WSS 3.0 server.

 

The command must be run as an administrator on the server and is (usually) located here : %CommonProgramFiles%\microsoft shared\web server extensions\12\bin or commonly called “the 12 hive”.

 

With this command you can almost completely manage your server, and perform actions or tasks that you are not able to do through the Central Administration site. Examples are: Import /export sites,

 

Tip! You can add this folder to your servers’ environment variables. This way, the command can be run from anywhere on the server.

 

Here are some commands that come in handy:

 

Backup

 

stsadm.exe –o backup –url SITEURL –filename BACKUPFILENAME –overwrite -backupmethod <full or differential>

(where –overwrite and –backupmethod are optional parameters)

 

When the url parameter is used, a backup of the site collection is created. However when the backupmethod parameter is used, a backup of an individual database, Web application, or the entire farm can be created. If you want to overwrite an existing backup file for a site collection only, use the overwriteparameter.

 

* Preferably, only do this when your site is not used. Usage can/could lead to corruption of your database backup.

 

There are a couple of limitations to this command:

  1. A farm backup cannot be used to restore the configuration database or Central Administration content database.
  2. Site collection backups affect performance, and they can cause access errors. They should only be used when the site collection is locked. Site collection backups can be slow when working with collections larger than 15 GB. This problem seems to have been resolved in WSS SP1. the backup command will first lock the site collection.

 

I do suggest that you use SQL Management studio (Express) to backup your content database.

 

Restore

 

stsadm.exe –o restore –url SITEURL –filename BACKUPFILENAME –overwrite –restoremethod <overwrite or new>

 

When the url parameter is used, a restoration of the site collection is performed. However, when the restoremethod parameter is used, a restoration of an individual database, Web application, or the entire farm can be performed. If you want to overwrite an existing site collection, use the overwrite parameter.

 

* Preferably, only do this when your site is not used. Usage can/could lead to corruption of your database backup.

* I do suggest that you use SQL Management studio (Express) to backup your content database.

 

Export

 

stsadm.exe –o export –url SITEURL –filename FILENAME –overwrite -includeusersecurity

(where –overwrite and –includeusersecurity are optional)

 

With this command you exports site and sub site data from your site collection.

 

Import 

 

stsadm.exe –o import –url SITEURL –filename FILENAME -includeusersecurity

(where  –includeusersecurity is optional)

 

Imports site and subsite data into your site collection.

 

Note on backup up:

It is recommended to use import/export and backup/restore in he folowing ways:

Import/export:  Backups of portions of a site

Backup/restore: Full site collection Backups

 

Rename a sub site URL

 

stsadm.exe –o renameweb –url SITEURL –newname NEWSITENAME

 

Careful, this just changes the URL of a subsite

Rename Site

stsadm.exe –o renamesite –oldurl OLDSITEURL –newurl NEWSITEURL

 

This command changes the URL of a host-named site collection to a new URL.

 

Repair Database

stsadm.exe –o databaserepair –url SITEURL –databasename DATBASENAME –deletecorruption

(where –deletecorruption is optional. you should run the command first without, to see if any repairs can be made)

This command detects and removes orphaned items from content databases in Windows SharePoint Services. In some situations, a content database that is used by Windows SharePoint Services may become corrupted. The corrupted database may contain orphaned items.

The databaserepair operation can detect and repair database corruption for only the following types of orphaned items in a content database:

 

  • A Windows SharePoint Services Web site that does not have a parent Windows SharePoint Services Web site

  • A subweb that does not have a parent Windows SharePoint Services Web site

  • A list that does not have a parent Windows SharePoint Services Web site

  • A document that does not have a parent document library

  • A list item that does not have a parent list

  • A Web page that does not have a parent Windows SharePoint Services Web site

Other types of corruption will not be repaired.

 

Add a solution

 

stsadm.ex -o addsolution –filename

 

This command is used to import a WSP solution package. Most of the time these are webparts that you can get from 3rd parties. An example is the RSS ticker web-part from Amrein Engineering.

Technorati Tags:

 Posted by at 12:55  Tagged with:
Oct 082010
 

For a few reasons you will need to be able to connect to your SharePoint content database. You cannot do this in a proper way using the tools you get standard with the WSS server.

 

The best (or most logical) way of doing this is using Microsoft’s SQL Management Studio, but you can also use the free Express version.

 

Most people that run a single WSS server do this because of budget limitations and can therefore not afford the licensing cost of a fill SQL server licence. The Express version is free and allows you to do most of the maintenance on your database.

 

There are, however, a couple of problems, or things to know before you can use SQL Management Studio Express SQL MSE on your WSS content database.

 

First, you need to install SQL MSE on the server itself. It does not allow you to connect to the database on your server remotely.

 

Second, once installed, you cannot connect to localhost. This will give you below error:

image

 

You will have to use the following connection string:

\\.\pipe\MSSQL$MICROSOFT##SSEE\sql\query

 

This will directly open up your local databases.

 

Software downloads:

 

Microsoft SQL Management Studio (Part of full SQL Install, Trial download here)

Microsoft SQL Management Studio Express

Technorati Tags:

 Posted by at 09:35  Tagged with:
Oct 042010
 

There are different reasons why you would need to get a value from the URL string:

 

- You are creating a customised form, say for a different user group

- You would like to pass on a variable from one form to another page/form

- Etc.

 

This is fairly easy to do, even using MS SharePoint Designer.

 

In this example, I made a new Dispform.aspx for a specific group of users, who should only see parts of the stored data. The standard list Dispform.aspx shows all values stored, which is required for the list administrator, or owner.

 

The only value that we need to read from the URL is the ID of the entry. in the URL this would be a link like this: “…onForm/ViewItem.aspx?ID=60

 

First, Create the new file, ViewItem for example, and add all the fields we would like to display as a Single Item View.

image

 

Now we will have a page which, by default, will show the last entry in the database.

 

We will now have to create a new parameter, containing the value from the URL.

 

On the little arrow on the top-right corner of your form, the “Common Dataview tasks”, select Parameters.

image

 

Hit the New Parameter button, and use Query string as the parameter source, Give the variable a name, and a default value (I usually use 0 to prevent people accessing data if they are not supposed to)

image

 

Now, you can use this parameter as a list filter:

image

 

Hit the little arrow on the top-right corner of your form, to get the “Common Data view tasks”, and choose Filter.

 

In the filter criteria, make sure the field called ID (the data from the list) matches your created parameter.

Technorati Tags:

 Posted by at 15:54  Tagged with:
Sep 292010
 

When creating a custom form for data input, You would probably like to redirect the browser to show a different page, like a “Thank you for submitting this form” page.

The standard action when you click on submit though, is that the form submits the data to the SharePoint content database, and then reloads the newform.aspx.

This gives users the idea something went wrong, and fill it in again. And again… Until they complain to you.

The solution is really simple. You would need to think of where you will send your users to, for example a new thank you page. Create this page first.

Then in the form you would like to add this functionality, click on the submit button and have a look at the code behind it:

onclick=”javascript:{ddwrt:GenFireServerEvent(‘__commit}’)}”

Now in the source code, change this to:

onclick=”javascript:{ddwrt:GenFireServerEvent(‘__commit;_redirect={thankyou.aspx}’)}”

where thankyou.aspx is the page you want to send the user to after submitting the form.

image

From Microsoft MSDN:

public string GenFireServerEvent(string szEventStr)

Generates a hyperlink used to fire a server event with a call to __dopostback(), which is the function called in ASP.NET to do a post back to the server. The szEventStr is the actual event text to fire.”

This means that what you are doing is adding parameters to the forms post back event. There are more than just __commit or __redirect. For example you can use

__workflowStart to start a workflow.

Caveats:

When you make a custom form for an existing list, there are a few small things to keep in mind.

  • Logout of all WSS pages you have open in your browser, Changing the default new item form (The form that opens when you click on the New Item Button in a list) will be set back if you are logged in. Why, dunno, don’t care, It’s Microsoft and it works like that ;)
  • Also, it seems that if you have paths with spaces this does not work and I have not (yet) found a workaround for it.

Technorati Tags:

 Posted by at 17:58  Tagged with: