SharePoint Blog

Sharing SharePoint Stories and Experiances

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

How to automatically provision SharePoint 2010 WIKI pages content


In this post we will discuss SharePoint 2010 Wiki pages. For site built on SharePoint Foundation without any Publishing features, WIKI experience is the closest you will get to SharePoint Publishing without requiring SharePoint Server. This, among other things, make WIKI pages so popular.
As such, you will probably want to know how to publish custom WIKI pages and provision content to them.
Assuming you already know all there is to know about provisioning regular pages (hint: watch the screencast above), we’ll dive right into adding a WIKI page to your Visual Studio solution.

1. In your Visual Studio SharePoint 2010 solution add a new project item of type Module and call itWIKIPages
2. Assuming you have a WIKI library provisioned on another site, connect to that site using SharePoint Designer 2010 – SPD.
3. Locate the WIKI library with SPD, and open one of the pages in edit mode and copy it’s content into clipboard.
4. Add new item to the Module you created above (WIKIPages) of type Text File and name it:Home.aspx
5. Open the file added to the solution explorer and paste the contents of clipboard to it.
6. In the paste code, locate the contents between:

<SharePoint:EmbeddedFormField id="WikiField" FieldName="WikiField" ControlMode="Display" runat="server">
...
</SharePoint:EmbeddedFormField>

And copy the content. This is actually the content of the current WIKI page and the field WikiFieldholds the WIKI content.
Now, how to add your own content.

7. Switch to the Elements.xml in the module and assign new value to the WikiField as shown below:

<Module Name="WIKIPages">
    <File Path="WIKIPages\Home.aspx" Url="SitePages/Home.aspx" >
      <Property Name="WikiField" Type="string" Value="
<div>
<table id="layoutsTable" style="width:100%">
<tbody><tr style="vertical-align:top">
<td style="width:100%">
<div style="width:100%">
<div style="min-height:420px
">[your content goes here]</div>
</div>
</td>
</tr>
</tbody>
</table>
<span id="layoutsData" style="display:none"
>false,false,1</span>
</div>
"/>
    </File>
</Module>

Notice in the layout structure of the WikiField you find [your content goes here], this is the content that will be provisioned into the WIKI page
In here Site Pages is the name of the WIKI library on my root site where the Home.aspx will be provisioned.

Note that you will need to remove any special characters in the WikiField value you must replace them accordingly otherwise the content will not be provisioned.

such as < > and “

How To Get started with branding of Office 365 public SharePoint site


In this post we discuss about using SharePoint Online in Office 365 as public SharePoint site. This is a quick way to get any public site online using SharePoint. This feature is available with personal or small business subscription as well as enterprise.

If you’re used to a traditional SharePoint team or publishing site, Office 365 public site is not quite the same. You can access your page using http://%5Byour sitename].sharepoint.com/Pages/Forms/AllItems.aspx but when you try to edit one, the design experience is not your typical SharePoint out-of-the-box etc. The ribbon is there but it doesn’t have all the same options you see in team sites or publishing sites.

Image

In fact you can’t add custom web parts deployed to the site using the functionality on the ribbon and you can’t edit masterpage without consequences …
Yes, all I did is edited a comment, didn’t even change any code.

Image

Let’s take a look at how you can work around this limitation and make your office 365 public site editing experience more like a team site.
In here I’ll be using SharePoint Designer 2010 and in few posts I will post a Visual Studio solution.

1. Open your Office 365 public site using SharePoint Designer 2010.
2. Click Sub Sites from the left Site Objects menu.
3. You should see a team site called [your company ] Team Site; click on it so new instance of SharePoint Designer opens that team site.
4. In the SharePoint Designer which has the Team Site opened, click Site Objects -> All Files -> _catalogs -> masterpage.
5. Copy v4.master; now go back to the SharePoint Designer showing the public site.
6. Paste the v4.master to the location from above on a public site and rename v4.master to something like new.master.
7. In Team Site SP Designer, copy Site Objects -> All Files -> default.aspx and paste it to the same location on the public site using SP Designer.
8. Right click on the newly copied file and select Set as Home Page. This will set a new home page which previously was a page in Pages/default.aspx, just in case you want to set it back.

Next, we’ll reference the new page to use our (to be) customized new.master

9. Right click on the default.aspx from step 8 and select Edit File in Advanced Mode.
10. Set the value of MasterPageFile to MasterPageFile=”~masterurl/new.master”

That’s it, now the home page is a newly copied collaboration-style page and it references our new collaboration-style masterpage.
The rest is like always: you can reference the CSS file from the Style Library, use images, JavaScript from libraries etc.
You will need to hide few collaboration placeholders and markup on a new.master so your public site looks like a public site but other than that – this will get you started.

Have Fun..!

How to maintain and configure, and backup and restore SharePoint 2010 databases


There are several ways to maintain and configure, and backup and restore SharePoint 2010 databases.  The obvious way is with SharePoint Central Administration, however, the easiest and perhaps best way is to use Windows PowerShell cmdlets.  There are many cmdlets available to use with SharePoint databases.

In this blog I’ll show more things you can do to SharePoint databases using Windows PowerShell. The following list is a mere sample of the SharePoint database tasks you can do by using Windows PowerShell:

  • Disconnect a local server computer from a farm — Disconnect-SPConfigurationDatabase
  • Connect a local server computer to a farm — Connect-SPConfigurationDatabase
  • Create a new configuration database — New-SPConfigurationDatabase
  • Remove a configuration database — Remove-SPConfigurationDatabase
  • Dismount a content database — Dismount-SPContentDatabase
  • Mount a content database — Mount-SPContentDatabase
  • Backup a SharePoint farm’s configuration — Backup-SPConfigurationDatabase -Directory <BackupFolder> -DatabaseServer <DatabaseServerName> -DatabaseName <DatabaseName> -DatabaseCredentials <WindowsPowerShellCredentialObject> [-Verbose]
  • Backup a complete SharePoint farm— Backup-SPFarm -Directory <BackupFolder> -BackupMethod {Full | Differential} [-Verbose]
  • Backup a SharePoint service application — Backup-SPFarm | -Directory <BackupFolder> -BackupMethod {Full | Differential} -Item <ServiceApplicationName> [-Verbose]
  • Restore a SharePoint farm’s configuration — Restore-SPFarm –Directory <RestoreShare> -RestoreMethod Overwrite –ConfigurationOnly
  • Restore a complete SharePoint farm — Restore-SPFarm –Directory <BackupFolder> -RestoreMethod Overwrite [–BackupId <GUID>]
  • Restore a SharePoint service application — Restore-SPFarm –Directory <BackupFolder> -Item “<ServiceApplicationName>” –RecoveryMethod Overwrite –BackupId <GUID> [-Verbose]

This list merely shows a small sample of what you can accomplish using Windows PowerShell when working with SharePoint 2010 databases.  For more details see the following topics:

 For help building and using Windows PowerShell cmdlets, see Bill Baer’s Windows PowerShell Command Builder available here,

 http://www.microsoft.com/resources/TechNet/en-us/Office/media/WindowsPowerShell/WindowsPowerShellCommandBuilder.html

Post Navigation