Configurating an external data type in SharePoint 2013 Part 2

This is part two of the series on configuring an external data type in SharePoint 2013. The first part is here.

At this point you should have already finished configuring the external data type, and created a list based on that external data type.

When you are trying to access the list you get an “Access Denied by Business Data Connectivity” error. This is caused by your configuration of your Business Data Connectivity Service. To change that you have to:

1. Go to “Manage service applications” in central administration

2. Click on the “Business Data Connectivity Service”

3. Select your external content type and click “Set object permissions”

4. Give full permissions to All Users(windows)

5. Now you should be able to see your list

Configurating an external data type in SharePoint 2013 Part 1

This is a step by step configuration of an external data type in SharePoint Designer 2013. The first part explains step by step how to create an external data type. The second part shows how to configure the connection for fetching the data from an SQL Server database that is on another server.

So without further ado let’s get to the step by step description:

1. Open SharePoint Designer

2. Go to “External Content Types” and click the “External Content Type” button

3. You will get a window with the new external content type configuration

4. Change the name of the external content type by clicking on it

5. Go to sources configuration

6. Click “Add Connection”

7. For the source type choose SQL Server

8. Specify the database connection properties

9. Now you are ready to connect to the SQL database. Create a table in your database if you haven’t already.

10. Your source connection should now be visible in SharePoint Designer.

11. Now you need to generate the possible operations on the ProjectsTest table. Make a right click on the table an choose “Create All Operations”

12. On the “Operation Properties” screen click next

13. Check if the parameters are configured properly, and if you have no Errors in the “Errors and Warnings” screen.

14. On the “Filter Parameters” screen click next

15. You can now see the defined “External Content Type Operations”

16. Now we can create a new list based on the external content type that we’ve just created. Go to “List and Libraries” and on the ribbon click on “External List”.

17. Pick our external content type and click “OK”
18. Choose a name for out external list and click “OK”

19. If the SQL Server database is on the same server you should see the list.

If the SQL database is on another server, than you will see an “Access Denied by Business Data Connectivity” error. Handling this problem is covered in the next part of this tutorial.

Customizing the MySites masterpage in SharePoint 2010

I recently had the task of branding our SharePoint 2010. I just needed to change the main theme colors. I made a custom SharePoint 2010 theme (a good description of the SharePoint 2010 theming engine is here), and that did it for the main masterpage.

A problem came up thought with the MySites masterpage. It has an additional div area under the navigation pane.

MySites navigation area

MySites navigation area

Unfortunately theming this additional area is not supported in the SharePoint 2010 theme engine. I don’t really understand why. It is a basic theming matter, that should have been taken into account by the SharePoint team. But as with many others aspects of SharePoint, it is, what it is.

I finally resolved this by changing the style of the div section. To change it’s color for example you need to embed this code in the masterpage code.

<style type='text/css'> {
        background-color: rgb(174, 3, 3)

How to programmatically deploy SharePoint 2010 Web Templates

Web Templates have been available in SharePoint already since the 2007 edition. I find that they are a really helpful feature, and provide a much easier and quicker way to set up a provisioning mechanism for SharePoint sites.

This blog post however is not dedicated to explaining what Web Templates are about. There is already some great material out there. Here are two links, that you should start with, to understand the pros and cons of web templates:

Vesa’s Juvonen great post, that goes into great detail about Web Templates:

Miriam van Olst post about Site Definitions vs. Web Templates

A tutorial on how to save a site as a Web Template, and what goes into it.

Ok, so you now decided, that you want to use a Web Template. It’s pretty straightforward and well documented how you can do it manually, but how to do it in code?

Step 1: Save the site as a web template(as explained in the article linked above), and download the created solution file.

Step 2: Upload the solution file to your solution library, and activate it.

SPSite currentSite = SPContext.Current.Site.Solutions;
string templateName = 'TestTemplate';
SPUserSolution userSolution = null;
SPFile solutionFile = null;
string templateFilePath = @'\Templates\TestTemplate.wsp'

// Gets the solutions gallery for this
SPDocumentLibrary solutions = (SPDocumentLibrary)site.GetCatalog(SPListTemplateType.SolutionCatalog);

// Check is a solution file with this name already exists. If it does, delete it.
if (!site.RootWeb.GetFile(templateName).Exists)
userSolution = (from SPUserSolution s in currentSite.Solutions
where s.Name == solutionName
select s).FirstOrDefault();

if (userSolution != null)

// Upload the solution file
solutionFile = solutions.RootFolder.Files.Add(templateName, File.ReadAllBytes(filePath), true);

// Activate the solution
if(solutionFile != null)
userSolution = site.Solutions.Add(solutionFile.Item.ID);

Step 3: Activate the site collection feature for the template.

Guid solutionGuid = userSolution.SolutionId;

SPFeatureDefinitionCollection siteFeatures = site.FeatureDefinitions;

var featureDefinitions = from SPFeatureDefinition f
in siteFeatures
where f.SolutionId.Equals(solutionGuid) && f.Scope == SPFeatureScope.Site
select f;

foreach (SPFeatureDefinition featureDefinition in featureDefinitions)
if (GetFeature(site, featureDefinition.Id) == null)
site.Features.Add(featureDefinition.Id, false, SPFeatureDefinitionScope.Site);

Afther that your template will be available for you to use.

Happy coding.

PowerShell SharePoint snapin adding scriptlet

If you ever tried to run a SharePoint script, and did not do it from the “SharePoint 2010 Management Shell”, you know what I mean. You got something in the lines of:

“The term x is not recognized as a cmdlet, function, operable program, or script file, blah blah blah”

That’s because the “SharePoint 2010 Management Shell” besides running PowerShell also loads a snapin with SharePoint cmdlets. You have to do that too. Behold the code:

$snapin = Get-PSSnapin | Where-Object {$_.Name -eq ‘Microsoft.SharePoint.Powershell’}

if ($snapin -eq $null)
Write-Host “Loading SharePoint Powershell”
Add-PSSnapin “Microsoft.SharePoint.Powershell”

You just copy and paste this on the beginning of your PowerShell script, and voila. You can now say bye bye to the “SharePoint 2010 Management Shell” shortcut.