Showing posts from 2012

Restore a previously restored SharePoint Site Collection with Restore-SPSite

In SharePoint you get an error if you try to restore a site collection that war previously restored. I always make a site collection backup of a site while I'm developing directly on a site and if i make any mistakes I restore the back with the Powershell command Restore-SPSite.

Common error messages were:

Restore-SPSite : The operation that you are attempting to perform cannot be completed successfully.  No content databases in the
web application were available to store your site collection.  The existing content databases may have reached the maximum number
 of site collections, or be set to read-only, or be offline, or may already contain a copy of this site collection.  Create anoth
er content database for the Web application and then try the operation again.

Reason The reason for this problem is that you can't restore sites or web which have the same id. SharePoint don't remove all ids when you delete a site collection. (Don't know why)

Solution In all other blogs y…

Open Document directly in Edit Mode within SharePoint from an Email link

If you send a link to a SharePoint document with Email to another user, the document is opened in read only mode. It is not possible to open it directly in Edit Mode.

Therefore I wrote a little JavaScript which can do that easily.

Steps to implement:

1.) Create a new page on the sitecollection you want to have this ability. Name it OpenDoc.
2.) Add the "XML-Viewer" WebPart from "Content Rollup" category.
3.) Open the WebPart Settings of the XML-Viewer WebPart
4.) Click on XML-Editor Button and add following JavaScript into it:

<script type="text/javascript"> ExecuteOrDelayUntilScriptLoaded(LoadDoc, "sp.js"); function LoadDoc() { JSRequest.EnsureSetup(); var file = JSRequest.QueryString["file"]; if (typeof file != "undefined" && file != "") { var baseUrl= "http://sharepoint/sites/mysite"; var host = location.protocol + "//" +; var docUrl…

Open SharePoint 2010/2013 Display, Edit, New Forms in Modal Dialogs

If you want to open a SP 2010 or in SP 2013 list item in a modal dialog you have two choices. Using the standard JavaScript functions or creating own functions.

How to find which item URL is called
If the dialog box appears you don't have an address bar to pick up the called URL. To see which URL is called when you edit or open a list item use the Internet Explorer Developer Tools.

Open your source list in the Internet Explorer. Press F12 to open the developer tools.

Click on the "Network" tab and then on "Start Capturing"

Now click the link you want to track.
You'll see the requests listed and you can also copy the urls for your need.

SharePoint usually calls the /_layout/listform.aspx with the list parameter. The form then redirects to the appropriate list form.

Method 1: Using core functions
When using SharePoint 2010 core javascript functions to open elements in dialogs mostly you'll need to know :

the ID of the listthe ID of the Content Typethe ID …

TFS - ItemNotFoundException on Reporting Server while creating new Team Projects

I had do deal with a problem while creating new Team Projects with Visual Studio 2010. The error message was that an an the item /Tfs2010OlapReportDS was not found.

It seemed that the reports for tfs could not be uploaded due a permission problem. After hours of searching and reinstalling I found the fix for the problem.

The fix was really easy.
Go to your team foundation server Open the administration console. Click on ReportingClick on EditClick on Reports TabEnter the credential for the ReportsSaveClick on Start Jobs

The whole exception message :

TF30162: Task "Populate Reports" from Group "Reporting" failed Exception Type: Microsoft.TeamFoundation.Client.PcwException Exception Message: The Project Creation Wizard encountered an error while creating reports to the SQL Server Reporting Services on http://tfs/ReportServer/ReportService2005.asmx. Exception Details: The Project Creation Wizard encountered a problem while creating reports on the SQL Server Reporting Se…

Using SharePoint Metadata Navigation in Enterprise Wikis

I thought it would be great to use the WikiCategories field in each Enterprise Wiki Page as navigation. This works relatively easy. SharePoint 2010 offers the new metadata navigation mechanism. We'll us it to create the page.

1. Goal
2. Create Enterprise Wiki Site I had a Team Site and I wanted to create an "Enterprise Wiki" subsite. To use the Wiki site template you must first activate the "Publishing Infrastructure" Feature in your sitecollection features.

The create a new subsite with the "Enterprise Wiki" template.

3. Adapt MetaData FieldClick on "Site Actions" menu on the wiki pageClick on pagesClick on Library in the Ribbon bar
Click on "Library Settings"Click on "Wiki Category" field
Adapt the field with the tags you want. The meta tags must be configured in the central admin within the metadata service.

4. Activate Metadata Feature Go to your newly create Wiki site.

Click on "Site Actions" menuClick on &qu…

SharePoint Use Confirmation for Site Owners

A problem in SharePoint is to keep content up to date. Therefore SharePoint offers the possibility to create use confirmations. The only problem is that the confirmation can only be approved by the site collection administrators. Not in all companies the site collection admins are also the site owners. This can be due to permission restrictions or other actions that a normal site owner should not do.

In this post I'll show you how you can create your own confirmation rules and pages without using visual studio or SharePoint solution files.

Standard Site Use Confirmation SharePoint offers an out of the box site confirmation mechanism. It send an email to the site collection owner and updates a counter of how many times a mail is sent without receiving a confirmation. The mechanism does not check the real use of the site. It simply send an email after a period of time to check the use.

You can configure it in the Central Administration  under "Application Management". T…

SharePoint 2013 Developer Training Site

Found this useful site in the microsoft homepage. It contains multiple videos for SharePoint and Office 13 developers:

Sorted Dropdown for MatchPoint Form WebPart with Distinct Elements

MatchPoint is a handy framework for creating fast custom solutions. In this post I'll show you how you can bypass some limitations with the Form WebPart.

A customer of mine wanted a sorted select in his form webpart in which he can choose the assigned user of a task list. Something like that:

1.Attempt - The SPListChoiceProvider You can do this easily with a ChoiceField in the Form WebPart. As provider (Source of the Dropdown) a SPListChoiceProvider would be a logical choice.

In the SPListChoiceProvider you can select the source list, a key and a value column for the dropdown. Additionally you can also select "UseDistinctValues" to remove duplicate entries.

One drawback or missing feature here is the ability to choose an order for the elements. Another is that you can only choose a single field as key. There is no possibility to combine fields.

2. Attempt - The ExpressionChoiceProvider My second attempt was to use the ExpressionChoiceProvider. With this provide…

Localization with SharePoint 2010 and Visual Studio 2010

A good resource management is essential when you working with SharePoint. Most custom solutions are not really localized although it's not so difficult to implement. In this post I'll show you which resource types exists while developing SharePoint solutions.

Resource Types When you develop SharePoint solutions you'll be creating different types of solution items. This includes:
FeaturesWebPartsASPX PagesCustom Code Each of these three items can output something to the user, so each of them must have localization capabilities.

Resource Locations You have multiple locations where you can position your resource files. Each location is used by another item and has other code methods.
\14\Template\Features\<Feature Name>\Resources\\14\Resources\\14\Config\Resources\<Virtual Directory>\App_GlobalResources\ In this post you'll understand in which cases which folder is used. Only Nr. 3 (\14\Config\Resources) folder is not used in any of the following exampl…

Colorful SharePoint Calender

Never knew that you can combine multiple calenders in SharePoint 2010 to a single calender view. The function is called overlaying. Moreover you can define a color for each view, all OOB. I found this great post how you can colorize your SharePoint calender: One drawback, which happened to me after overlaying was that the overlayed calender items could not be opened in the new SP 2010 Dialog style but only as new browser window.

Tip: If you have embeded the calender as webpart somewhere in your site, you have to actualize the view in the WebPart settings to view the colored calender.

Replace row numbers from copied code

This has nothing to do with SharePoint but I wanted to share the trick. When you copy code from some pages sometimes you have to copy the ugly row numbers, like

1: function XYZ
3:     var a = b;

You can delete these numbers easily with NotePad++ or another higher TextEditor. I use NotePad++ so I'll show you have I do that with NP.

Copy the code into the editorOpen the "Replace" dialogCheck "Regular Expression"Enter the regular expression in "Find What" = \d*: (This can be any other regex)Enter nothing into "Replace String"

Check Ports for Extranet SharePoint Farms with PowerShell

When you create a SharePoint Farm within an extranet you usually have to check ports to other servers within other security layers behind firewalls. Here is a simple script for a quick check. Copy this script to every SharePoint Server and modify the ip addresses. Run the script on the server to see if a port is blocked.

<# These values can be modified Enter the IPS of the server Ports from #> $SERVER_APP = "" $SERVER_WEBAPPS = @("", "") $SERVER_DB = "" $SERVER_AD = "" $SERVER_DNS = "" $SERVER_SMTP = "" $CLIENT = "" #IP of a client which should access SharePoint $USE_KERBEROS = $false $USE_NETBIOS = $false $USE_SMTP = $true # bi = bidirectional # out = outbound $CONNECTIONS = @( #SQL ( "out", $SERVER_APP, $SERV…

Synch User Fields when copying lists from one sitecollection to another

If you copy a list from one sitecollection to another one with a list template and the copied list has user fields than you'll have other users in the destionation list.

This occures because SharePoint saves all user in a own UserInfo table for each sitecollection. A user in SiteCollection 1 can have the ID 5 and in another the ID 3.

As the SPUserField is a LookUp Field to the User Info List the name of the User in the destination list can change.

Two little PowerShell Scripts can help here. The first one reads the user info for a field in the source list and creates a csv with the information. The second one reads the csv and updates the destination list. Copy the code to two .ps1 files.

Open the SharePoint 2010 Management Shell and run the "Dump user Info" script to dump the infos to a .csv file. Afterwards run the second script to update the destination list.

Dump User Info # Adapt these values $web = Get-SPWeb "http://sharepoint/sites/sourcelist/" …

Copy SharePoint Lists between sites with different language templates

An easy way to copy a list with content between to sites is to create a list template, upload it in the other site to the list template gallery and create a new list with the uploaded template.

The problem starts when the site templates have different languages. For example you create a list template in a site with english site template and you upload it to a site with a german site template, you'll not see the template in the create page.

A way to change this ist to modify the.stp file, which is created when you make the list template. SO the first steps are:
Create a list template. You can do this in the list settings. Just click "Save list as template" and give in the the filename and the template name.Download the created template to a local folder. Extract the template file Now we will modify the .stp file. An .stp file is nothing more than a microsoft cabinet file. Therefore rename the file from "mylist.stp" to "". You can now open…

Item-Level Permission for a SharePoint Document Library

The SharePoint Document Library doesn't have the option in his UI-Settings to change the item-level permisssions like normal SharePoint lists.

This means that you can't create a document library in which only user who created the documents can only see their documents and no one else.

You can simulate the behaviour by changing the permissions on each single document but this could be expensive and could also cause performance issues on  large libraries.

The better option is the activate the item level security by PowerShell. It seems that Microsoft  only disabled the UI Option but with PowerShell you can reactivate it. I don't know why Microsoft disabled this option but in my tests this method worked very well.

$web = Get-SPWeb http://YourSite/ $list = $web.Lists["Your Document Library Name"] $list.ReadSecurity = 2 $list.Update() $web.Dispose()
What the values for ReadSecurity property means can be seen here.

There is also a property for the write…