SharePoint Blog

Sharing SharePoint Stories and Experiances

Archive for the tag “SharePoint 2007”

Search, Filter or Sort Lists from a Query String in SharePoint 2007, 2010 and Office 365


What’s a Query String?
A query string is a collection of more or more parameters added to the end of a URL. You see these throughout SharePoint and at most interactive web sites. As an example do a search using Bing.com for “techtrainingnotes”. After you click the search button your search text is appended to the URL and will look something like this: http://www.bing.com/search?q=techtrainingnotes. The first parameter in a query string is identified with a question mark and each additional parameter is identified with and ampersand. Here the parameter name is “q” and the value is “techtrainingnotes”.

For the filter and sort tricks we will create a URL that looks something list this:

http://intranet/sites/training/Lists/Tasks/AllItems.aspx?FilterName=Title&FilterMultiValue=Task 2

The first part, “http://intranet/sites/training/Lists/Tasks/AllItems.aspx” is the path to a view of a list and everything from the question mark to the end is the query string.

Filtering One or More Columns
To filter a task list to show just “In Progress” tasks you would first visit a view that included the Status column. The URL to this list would look something like this:

intranet/sites/training/Lists/Tasks/AllItems.aspx

To filter this view you would add two query string parameters to the URL that specify the column to filter on and the value to filter for. This URL might look like this:

intranet/sites/training/Lists/Tasks/AllItems.aspx?FilterField1=Title&FilterValue1=In Progress

You filter on more than column by adding additional FilterFieldX and FilterValueX parameters to the URL. To find all of Luis Bonifaz’s In Progress tasks you might use this query string:

?FilterField1=AssignedTo&FilterValue1=Luis Bonifaz&FilterField2=Status&FilterValue2=Not Started

Why “AssignedTo” and not “Assigned To”? List columns can have an internal name and a display name. You will always need to use the internal name in these queries. See “Finding the Real Column Name” at the end of this article to see how to find these internal names.

Notes:

There can be multiple filters per query named FilterField1, FilterField2, FilterField3, …, FilterFieldxxx

FilterNameX is the column we are searching in – this column must be displayed in the page… i.e. it must be in the current view.

FilterNameX is case sensitive! A misspelled or miscapitalized FilterNameX column name causes the filter to be ignored and returns all rows from the list… So “Title” works and “title” does not.

FitlerNameX must be the internal name, which is not always the display name (details on how to find this name is at the end of this article)

FilterValueX is not case sensitive – searches for “in progress” and “In Progress” return the same results

FilterValueX does not support wild cards

All of the filters are AND’d together – i.e. the row in the list must match all of the filters to be displayed

Filtering a Single Column with Multiple Values and Wild Cards
The FilterField/FilterValue parameters can only find exact matches and only on a single value per column. You can also use “FilterName=” and “FilterMultiValue=” parameters to filter a column on more than one item or with wild cards. If you want to display all “In Progress” and all “Completed” tasks you could use this query string:

?FilterName=Status&FilterMultiValue=In Progress;Completed

You can also use wildcards in FilterMultiValue parameter:

?FilterName=Title&FilterMultiValue=*meeting*

You can combine FilterField/FilterValue with FilterName/FilterMultiValue when needed. Here’s an example to find all of Luis’s tasks with “meeting” in the task title:

?FilterField1=AssignedTo&FilterValue1=Luis Bonifaz&FilterName=Title&FilterMultiValue=*meeting*

Notes:

FilterName is the column we are searching in – this column must be displayed in the page… i.e. it must be in the current view.

FilterName is case sensitive! A misspelled or miscapitalized FilterName causes the filter to be ignored and returns all rows from the list… So “Title” works and “title” does not

FitlerName must be the internal name, which is not always the display name (details on how to find this name is at the end of this article)

FilterMultiValue is not case sensitive – search for “in progress” and “In Progress” return the same results

FilterMultiValue supports wild cards! – Searching for “task*” finds “Task 1”, “Task 2” etc

As FilterMultValue contains the word “Multi” then you would expect to be able to filter on multiple terms… and you can – separate each term with a semicolon (;) like this: &FilterMultiValue=In Progress;Not Started
Be careful not to add any extra spaces. The following will not find “Not Started” because of the extra space after the semicolon: &FilterMultiValue=In Progress; Not Started

To sort the items
You can use the SortField/SortDir to sort on any column in the view:

?SortField=Title&SortDir=Desc

Sort can also be used with the other filters:
?FilterField1=AssignedTo&FilterValue1=Luis Bonifaz
&FilterName=Title&FilterMultiValue=*meeting*
&SortField=Title&SortDir=Desc

Filtering from Quick Launch and other Links
So how do you use this little tidbit of information? You can generally do what these filters do with a view. Views do have one have annoying limitation… you can only display the first 50 views created. Technically you can create more than 50, but only the first 50 get displayed. Besides, it’s kind of tedious creating all of those views.

Let’s say you have a list with your 350 retail stores and you wanted to be able to quickly display a view of the stores filtered by any one state. You could create the 50+ views (50 states plus the other postal codes), or you could:

Add links in Quick Launch to selected states:
intranet/sites/training/Lists/Tasks/AllItems.aspx?FilterField1=State&FilterValue1=Ohio

Create a links list with all of the state codes and display it as a web part

Create a links list with all of the state codes, but display it as a dropdown list

Create an HTML dropdown list with the state code and add a little JavaScript to create the filtered URL and redirect to it

Finding the Real Column Name
The column name used as the FilterName parameter must be the internal name used by SharePoint, not the displayed name. As an example, in a task list there is a column named “% Complete”. The internal name of this column is “PercentComplete”. To find this name:

Display the list
Click the List (or Library) tab in the ribbon and click List (or Library) Settings
Scroll to the bottom or the page and click the column name
Explore the URL to find the internal name

intranet/sites/training/_layouts/FldEdit.aspx?List=%7B64C528B3%2D224B%2D4613%2D9D60%2D216300B5BCE0%7D&Field=PercentComplete

Simple Naming Conventions that Improve End User Experience in SharePoint Sites


This post is about How simple naming conventions can optimize URL length, readability and both power users and end user experience in SharePoint.

1. Create List, Library, and View names using “CamelCase” and change Title to user friendly names with spaces between words after the asset is created.
2. Use underscores “_” to separate words in document names and use the Title column to create “friendly names” for documents.
3. Use periods in front of group names for custom columns and content types so that your site-specific groups sort to the top of lists that are exposed to power users.

Background

First, remember SharePoint itself isn’t responsible for inserting the “%20” characters in your URL’s. This is what happens when your references are “URL encoded.” A single character space in a name translates to %20 (3 characters). Since your URL cannot be longer than 255 characters and the %20’s are not very readable, it’s a good idea to eliminate as many spaces as possible – without compromising usability. As with most user experience items, you need to balance both readability with usability. For the most part, the one tip to remember is to create most assets that “power users” can create (such as Sites, Lists, Libraries, and Views) using “camel case” names – in other words, smushing words together with no spaces but using capital letters to distinguish the words, for example: CamelCase.

Second, the %20’s aren’t the only naming convention issue that confuses users. Another annoying issue for users with Full Control privileges is finding custom columns. The default group for custom columns is “Custom.” That’s not a horrible name, but it doesn’t really help folks get much context for your columns. If you create a group called “Our Department Columns,” you will give users more context, but groups are sorted alphabetically by name when users are given the option to use them and your users are going to have to do a lot of scrolling to find the groups you want them to choose from if your group names don’t start with “A.” So, I’ve got a trick you can use to improve the user experience for Column and Template group names.

Naming Conventions for Users with Permission to Create New Sites, New Pages, Site Columns, Content Types or Page Templates

1. Create meaningful names for your custom columns or content type groups or custom templates – use a name that is associated with the most common way that the objects will be used. For site column or content type group names, it’s OK to use spaces between the words. So, an acceptable name would be Company Name Columns (where the name of your company replaces Company Name). This is better than “custom” because users will know that the columns were specifically created for your solution. But this alone isn’t enough.
2. Precede your group name with a period – for example “.Our Department Columns”. That little period has a really powerful effect – it will automatically force your custom groups to sort to the top of the list of groups that are exposed to your users. Try it, you’ll be surprised how much easier your life will be even as a developer. (I’ve asked a lot of really smart SharePoint architects and they assure me that adding a period to the front of custom group names will not cause any technical issues in your site. It’s just a naming trick to make your custom content types and columns sort “above” the “out of the box” ones.
3. Use the same trick with custom Page Templates. In the ideal scenario, remove templates that you don’t want your users to use so they don’t even see them. If that’s not feasible, put a period in front of your custom template names so that they will sort to the top of lists when users are given selection options when they create new pages.
4. Create all Site, List, Library, and View names using CamelCase and then after the list, library or view is created, go back in to the settings and re-name the Title (or view name) to include spaces in the names. This will eliminate %20 in the URL and still support a friendly end user experience. (It’s like having your cake and eating it too!)
5. From an end-user perspective, I don’t have a user-friendly technique Pages or Folders. If you create Pages or Folders with CamelCase and then change the name to add spaces, the new URL will have %20’s replacing each space. For Page Names and Folder Names, you’ll need to decide whether you can either live with the %20’s in URLs (my preference) or use underscores to separate words.

Naming Conventions for Users with Document Contribution Permissions

1. SharePoint won’t allow many special characters in file names so make sure you document these characters for your end users. The hyperlink in this bullet connects you to a Microsoft knowledge base article that details all the restrictions.
2. Since folder and file names become part of your URL, you should try to eliminate spaces when you create them so that you don’t have the %20 characters in your URL’s.

Creating Documents

1. Use an underscore (“_”) in place of a space between words if file names have more than one word. Capitalize each word of the file name. For example: My_File_Name.docx. The underscore is the best option because pretty much all search engines understand the underscore as a word separator, which means each word will be part of the search index. Using an underscore eliminates %20’s in the URL and still allows each word of the file name to be indexed for search so this approach is definitely recommended over using spaces in file names.
2. To give your documents a “user friendly” name, use the Title column to create an additional name for your documents. In the Title column, spaces are fine. It’s a good idea to always have a non-blank Title because the Title is displayed by default in search results and in Content Query web parts.
3. One of the downsides of the underscore recommendation is that it is difficult to distinguish the underscore from a space in a hyperlink, but this is usually only a problem if someone is trying to copy down your URL by hand.
4. Try not to use hyphens or dashes to separate words. While search engines typically also recognize a dash or hyphen (“-“) as a valid word separator, I prefer the underscore because hyphens are used as break points to wrap text on separate lines. URL’s that contain hyphens often cause problems in email, a problem that I would bet that all of us have encountered at one time.

If you absolutely have to have Folders

1. If you care about 100% readability of URL’s, use underscores (“_”) to separate words in folder names. For example Folder_Name.
2. If you can live with eliminating the biggest %20 offenders (site, list, library, and view names), then use spaces to separate words in folders because the underscore is not as readable in views as a simple space.

Back up and Restore your Site Collection in SharePoint 2007


You can use the tools included with Microsoft Office SharePoint Server 2007 to back up and restore your site collections. The Stsadm command line tool offers a fast and flexible, command line-based approach to content backup and recovery. You can use the Stsadm command-line tool together with Windows Scheduler to schedule delayed or periodic backups.

For more information about how the data protection tools included with Office SharePoint Server 2007 compare with other tools for protecting the SharePoint data, see Choose backup and recovery tools (Office SharePoint Server).

Important:

If changes are made to the site collection during the backup process, the backup can become corrupted. Backing up large site collections can take a long time. To reduce the chance that user activity will interfere with a site collection backup, or that the time that is required to back up large site collections will exceed the available maintenance window, follow these recommendations:

• For the duration of the backup, set the site collection URL to read-only by using the Setsitelock operation in the Stsadm command-line tool. This lets users view content on the site, but prevents activities such as adding or changing content that interfere with the backup process. When the backup is complete, return the access setting of the site collection URL to its default state.

• If the size of the site collection that you want to back up is 15 gigabytes (GB) or smaller, use the Stsadm command-line tool as shown in the procedures that follow.

• If the size of the site collection that you want to back up is from 15 GB through 100 GB, use Microsoft SQL Server 2005 or Microsoft System Center Data Protection Manager 2007 to perform a full backup of the site collection database.

• If the size of the site collection that you want to back up is larger than 100 GB, use System Center Data Protection Manager to perform a differential backup of the site collection database.

For more information about backup and recovery tools, see Choose backup and recovery tools.

Back up a site collection by using SharePoint built-in tools
Use this procedure to restrict access to the site collection during backup by using the Stsadm command-line tool.

Important:
Membership in the Administrators group on the local computer is the minimum required to complete this procedure. Limit access to the site collection during backup
1. At a command prompt on the drive on which SharePoint Products and Technologies is installed, change to the following directory: %COMMONPROGRAMFILES%\Microsoft shared\Web server extensions\12\Bin.

2. To determine the current access level of the site, type the following command, and then press ENTER: stsadm -o getsitelock -url where URL name is the URL of the site collection that you want to back up.

3. If the current access level allows changes to the site content, change it to read-only by typing the following command, and then pressing ENTER:
stsadm -o setsitelock -url -lock readonly where URL name is the URL of the site collection that you want to back up.

4. When the backup is complete, reset your site collection lock from read-only to none
stsadm -o setsitelock -url -lock none

Use this procedure to back up a site collection by using the Stsadm command-line tool.

Important: Membership in the Administrators group on the local computer is the minimum required to complete this procedure. To back up a site collection by using the Stsadm command-line tool 1. On the drive on which SharePoint Products and Technologies is installed, change to the following directory: %COMMONPROGRAMFILES%\Microsoft shared\Web server extensions\12\Bin.

2. Type the following command: stsadm -o backup -url -filename [-overwrite] where URL name is the URL of the site collection that you want to back up, and where \\server name\folder name\file name is the UNC path of the backup folder and the name of the file that you are backing up to. If there is an existing file for the backup, use the -overwrite parameter to overwrite the existing file.

3. If the backup is completed successfully, the Command Prompt window displays the following text: Operation completed successfully.

4. If the backup is not completed successfully, the Command Prompt window provides additional details about the failure. Most typically, an incorrect URL or file name was given.

Use this procedure to restore a Web application by using the Stsadm command-line tool.

Important:
Membership in the Administrators group on the local computer is the minimum required to complete this procedure. To restore a site collection by using the Stsadm command-line tool

1. On the drive where SharePoint Products and Technologies is installed, change to the following directory: %COMMONPROGRAMFILES%\Microsoft shared\Web server extensions\12\Bin.

2. To restore a site collection, type the following command, and then press Enter:
stsadm -o restore -url -directory -restoremethod overwrite where URL name is the URL of the site collection that you want to restore and UNC path is the UNC path of the backup shared folder.

3. When you receive a warning that all selected items will be overwritten, type y, and then press Enter.

4. When prompted, type the user name and password for the Web application and content databases.

5. If the recovery is completed successfully, the Command Prompt window displays the following text:

Operation completed successfully.

6. If the recovery is not completed successfully, the command Prompt window provides additional details about the failure.

Most typically, an incorrect URL or file name was given.

It is not possible to schedule backups from the SharePoint Central Administration Web site. There is no operation that enables you to automate backups by using the Stsadm command-line tool.

You can, however, automate the process by creating a batch file and then using Task Scheduler in Windows Server 2003 to run the batch file at a specific time. Because performance can be affected when doing backups with the Office SharePoint Server 2007 built-in tools, you might want to schedule your backups for off-peak times such as at night or on weekends.

Use this procedure to create a batch file that will run a full backup of your site collection. This procedure assumes that you have already created a shared folder for your backups.

Tip: When using Task Scheduler, make sure that the system date and time on your computer are accurate. To verify or change this information, double-click the time indicator on the taskbar. To create a batch file

1. Click Start, and then click Run.
2. Type notepad, and then click OK.
3. In Notepad, type the following text:

Copy Code

@echo off
echo ===============================================================
echo Back up sites for the farm to C:\backup
echo ===============================================================
cd \Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN
@echo off
stsadm -o backup -directory -backupmethod full -item
echo completed
4. where \\server name\folder name is the UNC path of the backup folder and where Web application name is the name of the site collection that you want to back up. You might use the full farm path notation as displayed by the showtree parameter or the name of the component in the path if it has a unique name — for example, Windows SharePoint Services Web Application\SharePoint-80.
5. In Notepad, on the File menu, click Save As.
6. In the Save As box, select the folder where you want to keep your batch file.
7. Use the “.bat” file name extension; type the name of the file in the File name box, for example, backup_batch.bat.
8. In the Save as type box, click All files.
9. Click Save.

To schedule a backup
1. Start the Scheduled Task Wizard, and then click Next.
2. Click Browse, locate the batch file that you just created, and then click Open.
3. Type a name for your task, for example, backup_batch.
4. Select how often you want this task performed (for example, weekly), and then click Next.
5. To automatically perform this backup periodically, select an interval such as Weekly or Monthly. To perform this backup one time, or to delay a single backup, select One time only.
6. Choose a time and start date for your backup.
7. Type a name and password for a user, and then click Next. This task will run as if it were started by that user.
8. Click Finish.

To configure advanced settings for the task, select the Open advanced properties for this task when I click Finish check box in the final page of the wizard. This opens the properties dialog box for the task when you click Finish.

You can then change the program being run on the Task tab, fine-tune the schedule on the Schedule tab, customize settings on the Settings tab, or set user and group permissions on the Security tab.

Courtesy: MSDN

Quick poll on work environment


Post Navigation