Tag Archives: xml

SharePoint Custom Solution Branding and Tips – Part 2

This is part 2 on how to brand your SharePoint Solution. If you haven’t read my part 1, please do so here.

Often than not, you would want to include your custom List Definition/Instance to be provisioned into your Solution file. In SharePoint 2013, they’ve changed the Site Content page drastically and you can’t really Ignore the BIG BIG icon for each List/Library within your site.

sharepoint site content list icon image

It’s fancy and it’s sleek. So how can I create one for my own solution?

As usual, there isn’t gonna be much documentation provided in MSDN. And most of the time, you just got to crack your head and dig your way out. I’m writing this post here so that you can at least Find my article when you’re googling around.

How to set Image for your List Definition / List Instance

Assuming you have already created a SharePoint 2013 Project solution and added a List Definition.

Add SharePoint “Images” mapped folder into your Project as shown below

right click add image layout folder sharepoint

Prepare TWO icons and you must ensure that the following rules are followed:

  1. Both icons must have same file extension.
  2. One icon is in 16×16 pixel size and the other one is in 96×96 pixel size
  3. File Name of the 16×16 icon must starts with small I: “it” e.g. itmyfancyicon.png
  4. File Name of the 96×96 icon must starts with small L: “lt” e.g. ltmyfancyicon.png
  5. Both file names must be exactly the same except for the first character.

To better helping you to understand, I’m including the two images used below

itmyfancyicon.png itmyfancyicon  (16×16)                  ltmyfancyicon.png ltmyfancyicon (96×96)

After meeting these rules, you need to include them into the Images mapped folder and be placed into the same Folder. (Must)

sharepoint list icon image same folder

Lastly, go to the Elements.xml file of the list definition and modify the Image Attribute to point to “it” (16×16 pixel size) image as shown below. DO NOT specify the one that starts with “L”.


Once you specified to the small “i” image, deploy it and you should see your List is having a nice and Correct images!




SharePoint Custom Solution Branding and Tips – Part 1

Today, I want to talk about some of the good practices when it comes to SharePoint custom code development. More often than not, you would learn that SharePoint custom solution requires you to create Feature (and usually it’s automatically created when you pick any of the default SharePoint Project template e.g. Visual Web Part) to deploy your web part, style sheet, JavaScript files, or master pages.

I can understand that the Microsoft VS team is trying to help SharePoint Developers setting up a working solution as easy and as best as they could. What we need to really take note or at least be aware of is those default values assigned to the template. Below are some of the items in which I personally think that it should not be left unchanged or not thought thoroughly in order to develop a quality solution.


Before even creating a new SharePoint 2010/2013 project, please think through the namespace that you want to use. Changing of namespace after you have tons of web parts, feature or pages will kill you. And I kid you not, using VS rename feature does not 100% guarantee you that the code will not break. I have experienced it, and it really takes you a lot of time to just renaming a namespace. (if you are new to SharePoint Development of course)

What I always like to use for namespace naming convention is as per below format

[Company Name].[Type/Name of the solution].[Sub type]

e.g. Microsoft.Branding, Microsoft.Branding.UserControls, Microsoft.Branding.DelegateControls

I would say it is not advisable to have more than 3 levels as it would introduce a very lengthy code referencing.

And I would also suggest using sub type like “UserControls”, “WebParts” or “WebPages” to organize your codes accordingly. It makes the next developer who is taking over your code easier to understand.

Feature Name

Sorry to say that this is one of the item that I dislike most when you found out that your developers did not use it correctly or not even care about changing the name of the feature!

You may not see the impact for now but once you have your code deployed to your customer’s SharePoint environment, it would really look bad and unprofessional to have this appearing in their Site Collection Feature or Manage Site Feature page.

sharepoint feature name bad practice

If you care enough, you will notice that only your custom feature’s name is ending with the numeric “1”. As if there is feature 2 and so on? LOL hell no!

Well, as a new beginner, you will likely to use the SharePoint – Visual Web Part template for a quick start.

sharepoint visual web part

What this template provides by default in the solution is the feature, package and a visual web part. Refer pic below

shareopint default feature name

Please please, remove the “1” and use a proper name.

Note that if you have already deployed your solution to production. After changing the name, you have to retract existing solution by running “Uninstall-SPSolution”, “Remove-SPSolution” and subsequently “Add-SPSolution” and “Install-SPSolution”. You should not use “Update-SPSolution” or else you will hit error deploying it.

Please also use a meaningful description. =)

Feature Image

The next thing I want to talk about is the icon of SharePoint feature. SharePoint by default assign an icon GenericFeature for your feature. As the image name suggested, it is a Generic Feature gif and in order to out stand or brand your feature, I would always like to use a custom image for my feature.

One simple reason is that it makes life easier when there is a lot of features within your SharePoint Site and you need to scroll through the entire list in order to activate or deactivate your feature.

sharepoint long list of feature

How to not miss the “EASY” icon if the color is outstanding enough. You know what I’m trying to say. Outstanding!

The following paragraph describes how you can actually add feature icon into your SharePoint Feature.

First of all, create a good icon for your feature, and put it into your SharePoint Solution.

sharepoint add images mapped folderSimply right click the project, hover to Add and click “SharePoint Images Mapped Folder” (if you already mapped, this option will be grey out)

Once you have it mapped, you can just dump your  images into the mapped image folder and it will automatically be included into your package. The relative URL of your images folder is always starting from “/_layouts/15/IMAGES/”

How to know if it is really going into that URL? You can check by looking into the Property of the Images mapped folder – Deployment Location where it stated “{SharePointRoot}\Template\Images”. This actually goes to your SharePoint 15 hives (SP2013) of your deployed server and if you look into IIS Manager for your SharePoint Web application. This folder is actually mapped as a Virtual Directory with path

sharepoint virtual directory image

Once you have your image prepared in the solution, next step is to tell your Feature to use the image. Easy. Go to your feature element files as shown below.

Simply place your cursor right before the end of the “>” tag and you should see the intellisence starting to show up. At this stage, the attribute that you would need to pick is quite self-explanatory.

sharepoint feature auto suggestion

Insert the ImageUrl. Just remember to make sure the url is correctly populated. Sample as shown below.

sharepoint feature image url example

Once you have it specified correctly, deploy it and you should see that your feature is now with your custom icon. Sample below shows not really a good example, but please use a size that you find fits.

sharepoint feature image output


Custom Action Group and Action

Another item that worth mentioning when doing SharePoint development is the Custom Action and Group. Since SharePoint 2010 (not sure about SharePoint 2007). It introduces a new feature where you can inject Stuff (could be links, could be Ribbon action or event Site Action) into certain area of your SharePoint pages.

Basically, the idea is that there is list of area (which it is called Location) in SharePoint where you can add/remove Stuff and within each area, there is another sub-area (which is called Group ID) if you need to further scoping down into a more specific area.

You can refer to MSDN https://msdn.microsoft.com/en-us/library/office/bb802730.aspx for Location and GroupID that you can make use of.

Things can be made easier if you need to display some custom site action or site settings link for your user to access certain page (be it your custom application page or SharePoint OOTB pages where it may not be displayed by default e.g. /_layouts/groups.aspx (Groups Page)).

I’m going to share how to go about doing it.

First of all, go to MSDN link above and identify the Location that you want to use. For the simplicity, let use Microsoft.SharePoint.SiteSettings as a example.

So let assume you want to insert a hyperlink into Site Setting page.

Go to your VS Project, Right click and add new item. Select Empty Element as shown

sharepoint empty element

Pick a nice name and hit Add. Note that once it is added, you can find a file called “Elements.xml” being added. Open it and,

Insert the following code.

sharepoint feature site setting example


Things that you need to note here is the GroupId and Location used. I added a Custom Action Group with a custom id, but using a valid Location. Subsequently, create another CustomAction and use the custom GroupId and the same valid Location (You still need to specify the same value as the CustomActionGroup or else it won’t work).

The Sequence in the Custom Action Group tells how earlier you want your group to be rendered in the Location. In the example above, 1 is being the first to render.

sharepoint site setting link


Hence it will be at the top of all existing group.

Things get a little bit complicated here if, let say other feature have used the same Sequence number as you did. In this case, the later registered ones will be displayed first.

Like example below. Group A being registered later and hence it is displayed first before the Group B.

sharepoint feature sequence does matters


Note that you need not to order the Custom Action xml to below Custom Action Group. SharePoint can still recognize them.


I have much more to share but that’s it for today! I hope above info and tips can help giving you some ideas and to be able to build a good SharePoint solution!


Read part 2 here

Change the default settings for newly created SharePoint Document Library

Thought it would be helpful to share this.

As you know, SharePoint Document Library by default, if you just simply create one, are not turned on with Version Control. This could rather prone to human mistake or mis-configuration whenever you need to provision a new document library.

This is how I fulfill this.

Imagine i need to have the version control turn on, and with the following settings

version history limits

What you need to do is to create a custom event receiver with List Added handler

Fire up your Visual Studio, create a SharePoint Farm solution and add your new event receiver

New Event Receiver

Select List Events and tick “A list was added”

Event Receiver Setting

In the ListAdded method, kindly do a checking before the code is firing, the below TemplateId 101 means Document Library

if (properties.List != null && properties.TemplateId == 101 && properties.Web != null)

 SPList docList = properties.List;//.Lists[properties.ListId];
 docList.EnableVersioning = true;
 docList.EnableMinorVersions = true;
 docList.MajorVersionLimit = 3;
 docList.MajorWithMinorVersionsLimit = 20;

//this.EventFiringEnabled = false;
catch (Exception ex)

//Do something...



If you do this, you will hit this error when creating a new document library

The security validation for this page is invalid. Click Back in your Web browser, refresh the page, and try your operation again.

This is due to the Synchronisation mode for ListAdded event by default is “Asynchronous”.
You MUST DO the following

Open the Element.xml created via Visual Studio.
Add a “<Synchronization>Synchronous</Synchronization>” node into your receiver xml


Deploy your solution and hooray~

SharePoint 2013 Pre-requisite Error – Application Server Role and Web Server (IIS) Role

Bumped into  this error when trying to manually setup SharePoint 2013 pre requisite installation.

The Configuration stopped at step Configuring Application Server Role and Web Server (IIS) Role.

SP2013 Error - Pre-requisite App Server and Web Server


  1. Go to Server Manager > Add Roles and Features
  2. Select Your server in the Server Pool under Server Selection page
  3. Select Web Server (IIS) Role
  4. Click Next until the wizard finishes
  5. Rerun the Pre-requisite setup and the error is gone.

namespace ‘xsd’ error when saving SharePoint Navigation

I bumped into this error when trying to set target audience for SharePoint Publishing Navigation.

This issue happened only on IE 10, if i used IE9, this error will not happen.

After several rounds of testing, it is confirmed that the IE 10 Browser Mode “IE 10” that cause this issue. I’m shocked that IE 10 default browser mode does not support SharePoint 2010.

In order to avoid this error, you’ve got to hit F12 “Developer Tool”, look at the toolbar and change the Browser Mode to “IE 10 Compatibility View“. Then this error will be gone.

Configuring SharePoint Calendar Overlay using Powershell

When comes to deployment, my always first rule is to automate the deployment steps.

You could always use site backup and restore for deployment. But that is not my preference, always. Simply because you can’t do this every time when you hit a problem or when you need to reconfigure the whole site.

Well, after some tracing on the Calendar list object class. I found the CalendarSetting property of calendar list.

Unfortunately, there isn’t a fully integrated API for you to configure SP calendar overlay. You have to parse the calendar setting in XML structure yourself. But that really isn’t bad.

You simply have to follow the structure as shown…

 <AggregationCalendar Id='%%RANDOM GUID%%' Type='SharePoint' Name='%%VIEW NAME%%' Description='' Color='2' AlwaysShow='True'
 CalendarUrl='%%Calendar URL%%'>
  <Settings WebUrl='%%WEB URL%%' ListId='%%LIST ID%%' ViewId='%%VIEW ID%%' ListFormUrl='%%DISPLAY FORM URL%%' />


%%RANDOM GUID%% : GUID e.g. “{76018083-3ed1-4a4c-b332-734106113448}”
%%VIEW NAME%%: View Name
%%Calendar URL%%: URL to the calendar that you want to overlay. e.g. “/Lists/My Calendar/calendar.aspx”
%%WEB URL%%: URL of your SharePoint site.
%%LIST ID%%: Calendar List ID that you want to overlay.
%%VIEW ID%%: View ID of the Calendar that you want to overlay.
%%DISPLAY FORM URL%%: Display Form URL of the Calendar e.g. “/Lists/My Calendar/DispForm.aspx”

Note the Color attribute for  AggregationCalendar, this attribute takes in the index number of the colour choices (you can refer to the SharePoint Calendar Overlay page for this)

Adding Powershell Script inside XML

At times, you will require to read your data in XML format using Powershell Script. Possible reason to do that is such that you can amend the XML file without editing your original Powershell Script. That’s provided that the standardized Powershell Script can fulfill your requirements.

To cater for More flexibility, you can actually insert Powershell Script within your XML. Here is how you can perform that.

Note that this required a minor change in your Powershell Script. (Not to worry, you only need to edit this once and for all).

$xml = (Get-Content .\yourxml.xml)

$expression = $xml.Scripts.script

#Optionally you can put a foreach loop to run each of your script

Invoke-Expression $expression

Below is the simple xml of mine

 <script>   Write-Host "Halo";   Write-Host "Testing";
The output looks like this
Adding Powershell script into XML

SharePoint InfoPath List vs Form Library

SharePoint InfoPath provides the following form templates. I’m kinda writing them down so that i can always refer back to this post and compare the pros and cons between the two most popular form templates.

SharePoint List:

  1. Simpler form.
  2. Quicker way to generate a form yet leverage on InfoPath OOTB Validation.
  3. All columns are stored in Custom List. Export to Excel feature is meaningful in this sense.
  4. Attachment Supported. User can add attachment on to the form as it is Custom List by SharePoint nature.
  5. Support multiple views.

SharePoint Form Library:

  1. Support more complicated form validation such as repeating tables
  2. Requires more knowledge on using the form designer.
  3. Custom fields are stored in SharePoint Library Columns. Not All can be stored, such as repeating fields.
  4. Attachment not supported. A form is stored in XML format. Search result may not be meaningful to the end user.
  5. Support multiple views.
  6. Support Repeating field! That is, the design can cater for dynamic number of record in a particular columns. For example, you want the user to enter the particular of their family members, which could be zero or more. In List, you can’t possibly allow this unless you hardcode the column to support up to a certain amount entry.

Add SPUser to SPGroup using Powershell

Adding user to SharePoint group manually is a painful process. Not to mention if you have tons of users using your SharePoint site.  To make life easier, I actually came out with a simple powershell script and XML (where you store the user mappings) to automate the process.

$webUrl = Read-Host "Enter SharePoint Web URL"
if($webUrl -eq "")
 $webUrl = "[Your default http]";
$web = Get-SPWeb $webUrl
$xml = (Get-Content .\PumpUser.xml)
#Put your xml (in this case 'PumpUser.xml') in the same folder where you place your powershell script
foreach($group in $xml.Groups.Group)
 $title = $group.Title
 $spGroup = $web.SiteGroups[$title]
 foreach($user in $group.Users.User)
  $temp = $web.EnsureUser($user)
  Write-Host "Added "$temp" to "$spGroup.Name

The xml goes like this.

<?xml version="1.0" encoding="UTF-8"?>
  <Title>Administrator Group</Title>

Simple and easy =)