Monday, December 24, 2012

How to add Taxonomy Fields To Page Layouts?

1)Create Site Column Of Type Manged Metadata and add this Site Column to Associated Page Layout Content type
For example
If Page Layout is associated  with Project Page,Edit Site columns to include this Manage Metadata columns

2)In SPD refresh toolbox  ,So that Managed Metadata field is visible  as shown in image, Drag this  field to PageLayout
Add taxonomy reference

<%@ Register Tagprefix="Taxonomy" Namespace="Microsoft.SharePoint.Taxonomy" Assembly="Microsoft.SharePoint.Taxonomy, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>

This field will be visible only when you create New Page using this Page Layout

Sunday, December 23, 2012

Importing Very Simple BDC Model

1)Create a SQL table in Sql DB 
2)Create New  External Content Type in SPD with SQL connection  with User's Identity as Authentication mode.
3)Create required operation like read, write for Table Created in SQL
4)In CA,In Secure Store Service , Create Target application which maps the Credentials for External Content Type (If necessary)
5)In BCS Service Application, Set the required permissions for External Content Type
6)Create The External List With this Content Type
When You browse the list , you come across to this exception
“Login failed for user “NT AUTHORITY\ANONYMOUS LOGON” while browsing to external list.”
To avoid this enable RevertToSelf Authentication Mode as described here
Now ,Set the Authentication Mode to BDC Identity.
7)Save the ECT and export this Model

8)Edit the .bdcm file and modify it according to production server as follows.Save  this file and Import this model in  Production server CA
 <LobSystemInstance Name="UserInfocon">
            <Property Name="ShowInSearchUI" Type="System.String"></Property>
            <Property Name="AuthenticationMode" Type="System.String">RevertToSelf</Property>
            <Property Name="DatabaseAccessProvider" Type="System.String">SqlServer</Property>
            <Property Name="RdbConnection Data Source" Type="System.String">ProdServer</Property>
            <Property Name="RdbConnection Initial Catalog" Type="System.String">DataBaseName</Property>
            <Property Name="RdbConnection Integrated Security" Type="System.String">SSPI</Property>
            <Property Name="RdbConnection Pooling" Type="System.String">true</Property>

Sunday, December 9, 2012

Silverlight Client Object Model For Windows Phone

In SharePoint 2010,Silverlight Client Object Model was not supported for Windows Phone
But This is improved in SharePoint 2013
As Windows Phone 7.5 first creates an object of the Authenticator class or ODataAuthenticator
which were added to the SharePoint 2013 client object model for Microsoft Silverlight for Windows Phone. It then uses this object as the user’s credentials.
Read more in this msdn post

Sunday, November 25, 2012

Wow!! Add SharePoint 2013 App Instantly

What an Interesting Ribbon this is !!

Now we should focus on converting the SharePoint Solutions in Apps, And that is  the SharePoint Future.

Sunday, November 18, 2012

Configure Anonymous Application Pages Without Enabling Anonymous Authentication

Without enabling the anonymous authentication on all list and libraries,It is possible to create few application pages anonymous.

1)Create in Mapped folder for Application Page in Solution Explorer.(Apply the masterpage which don't references css and js files from Style library)
2)In Code behind and .aspx of Application Page Inherit from UnSecuredLayoutBasePage
3)Implement URL authorization  (ASP.Net Concept)
In  Web.Config of this WebApp  add following section
(Use <location> configuration tag, and <allow users="?"/> to allow anonymous only or <allow users="*"/> for all
<location path="_layouts/MappedFolder/AnonymousPage.aspx">
          <allow users="*" />

Monday, October 22, 2012

Brand Configurable Left Navigation With WebPart

1)In SPD , create the Page from  Master Page as shown  in below image

2)Add the required namespaces  and  contentplaceholderid="PlaceHolderLeftNavBar"
In this contentplaceholderid Insert the WebPartzone.
Now ,you can configure Left Navigation On Fly,with the help of configurable webpart in this zone

<%-- _lcid="1033" _version="14.0.4762" _dal="1" --%>
<%-- _LocalBinding --%>
<%@ Page language="C#" MasterPageFile="~masterurl/default.master"    Inherits="Microsoft.SharePoint.WebPartPages.WebPartPage,Microsoft.SharePoint,Version=,Culture=neutral,PublicKeyToken=71e9bce111e9429c" meta:progid="SharePoint.WebPartPage.Document" meta:webpartpageexpansion="full"  %>
<%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> <%@ Register Tagprefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> <%@ Import Namespace="Microsoft.SharePoint" %> <%@ Assembly Name="Microsoft.Web.CommandUI, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> <%@ Register Tagprefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages" Assembly="Microsoft.SharePoint, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<asp:Content id="Content1" runat="server" contentplaceholderid="PlaceHolderLeftNavBar">
<table cellpadding="4" cellspacing="0" border="0" width="100%">
     <td id="_invisibleIfEmpty" name="_invisibleIfEmpty" valign="top" width="100%"> 
     <WebPartPages:WebPartZone runat="server" Title="loc:FullPage" ID="FullPage" FrameType="TitleBarOnly"><ZoneTemplate></ZoneTemplate></WebPartPages:WebPartZone> </td>
    <script type="text/javascript" language="javascript">if(typeof(MSOLayout_MakeInvisibleIfEmpty) == "function") {MSOLayout_MakeInvisibleIfEmpty();}</script>
To add the combined configurable left navigation and QuickLaunch check this link
3)To adjust the position of main contents and quicklaunch  apply this css

<asp:Content ContentPlaceholderID="PlaceHolderAdditionalPageHead" runat="server">
 <style type="text/css">

Note --> Above Quicklaunch will be available only for Particular Page or PageLayout
If you want to make this consistent through out the Site, You need to write the Delegate control with WebPart Zone ,check this post for creating delegate control.

Thursday, October 11, 2012

Content Approval Workflow Using Reusable Workflows

A)Reusable Workflow associated with Content Type In SharePoint Designer
1)Create the Site columns(similar columns that are created after content approval is enabled on Library) and add those  Site Columns to Content type Inherited from Document Content Type

2)In Document Library , Enable the Custom Document Content type as created in above step
and delete the existing document Content Type

3)Enable the Content Approval on this Document Library
Library Settings -->Versioning-->Select allow content approval option

4)In SharePoint Designer ,In Workflows tab,create new Reusable workflow(this is only the deployable workflow , so avoid creating list workflows , If unknowingly you have created List workflow see this trick, another trick)
Associate this Workflow to Content Type (created in step1)
One more..

5)Add this workflow to  Content Type Created in Step A 1
Edit the Custom Document Content Type, in workflow Settings  , Add the workflow instance using reusable workflow template as created above.

6)Save this Reusable workflow as Template in SPD  and download the required wsp from Site assets Library

B)Deploy reusable workflow to Production site
1)Save the site as Template (Test site where content type is created and associated with workflow )and Import into Visual Studio(select site columns ,Custom Document Content type  and Document Instance while importing.
Deploy this solution on production site (or create feature dependency).

2)Upload the wsp created in step A 5 and activate the Workflow  feature .
Or (Import  as Workflow in visual studio and create dependent feature on step B 1)

3)By default Document Workflow will not be associated with Custom Content Type.
When you import Reusable workflow ,Add the feature receiver which will  associate
Custom Document Content Type with this Workflow
Download the Source
In this source ,Association and Initiations forms are removed .you can add those if required.

C)Difference in Content Approval and Approval Workflow

Note -->For association of Content Type and importing wsp to Visual Studio, you can read this post

Thursday, September 13, 2012

Role Based Navigation:Role Based QuickLaunch

Its the common requirement  everywhere to create the RoleBased QuickLaunch and Global Navigation
Following code snippet hides the Firstnode of Quick Launch for Users other than owners and admins,
To implement this
Edit the Master Page in SPD and add this css along with SPsecurity Trimmed Control in head section of master page(Only in following sequence)

1)Following css will be available for all users

<style type="text/css">
/* mainlinks */
.menu-vertical > ul.root > li.static:first-child > .menu-item{

/* Sublinks */
.menu-vertical > ul.root > li.static:first-child   > ul.static  {


2)Following css will be only  available for Owners/admins

<SharePoint:SPSecurityTrimmedControl ID="sitePerms" PermissionsString="ManageWeb" runat="server">
 <style type="text/css">
 /* mainlinks */
.menu-vertical > ul.root > li.static:first-child > .menu-item{

/* Sublinks */
.menu-vertical > ul.root > li.static:first-child   > ul.static  {



For extensive branding of QuickLaunch following links are very useful

To Deploy , create the feature to replace the existing master page

Sunday, September 9, 2012

How To Create Solution Package To Deploy Lists With Lookup Columns

To save the time and work pressure,Some of the developers end up deploying lists by 'Save As Template' method.
My request to all those developers is not to go by that way(specially for new learners). Just take the advantage of ,What feature MS Visual Studio 2010 for SharePoint provides.
 Because there are several disadvantage of this ('Save as Template') method. and When it comes for the lists with Parent-Child relationship which includes lookup column it's terrible.
Not only for this post,think of deployment perspective while finalizing any approach for development.
To Develop solution package for Lists With Lookup Columns
A)Create Content Type and Site Columns for Parent List 
1)Navigate to any source SharePoint site.
Site action -->Site Settings-->Site Columns Create site column 'Parent Column' with Single line of Text

Now add this site column to Parent Content Type,
to do so,create new Content Type which inherits from List Content Type and add parent column

2)Create Custom List ParentList  and Enable management of Content Type of this List(List Settings 
-->Allow management Of Content Type
Add from existing  Site Content Type and Select Parent Lookup Content Type
and delete the existing Item Content Type

B)Create Content Type and Site Columns for Child List
 Site action -->Site Settings-->Site Columns Create site column 'Foreign Column' with Lookup Type as described in below image
  Now add this site column to Child Content Type  and Associate this content type with Child List in the similar way , as that of Parent List(As described above in Section A )

C)Get the wsp file of the site and Import to Visual Studio
1)Browse to _Layouts/savetmpl.aspx with include contents check box checked and save it to the local disk(this link is not visible for publishing sites in site settings)
2)Visual Studio 2010-->run as admin-->New Project-->SharePoint-->Import Solution Package.
Select deploy as Farm solution and select the wsp saved in above in Step  C 1.
Press Shift on Keyboard,select first and last row and uncheck all the files shown in grid
Now you have to be very careful.Make sure that following items are selected before clicking on next
1)Parent Column, Foreign Column(Child Column) site columns
2)Parent Content Type and  Child Content Types
3)Parent List Instance and  Child List Instance
4)ListParentList_Pages and ListChildList_Pages

On clicking Finish ,If you get Popup for  dependencies,Click on 'No'  and Solution should appear like below

Please add to the comments If you get any deployment errors.while doing this activity. I renamed the Child List before Importing.so I got the deployment errors for List not found .Then I ran replace all for new list name and Its working now :)

If during deployment few more columns and Content type needs to be deployed , get  the schema  through powershell add to this solution.

Download Source

Monday, August 27, 2012

SharePoint Designer Errors

When SPD throws the nasty errors like below and  which points to no hint, then there is only one way.
Restart the IIS and remove the temporary files :)

soap:ServerException of type 'Microsoft.SharePoint.SoapServer.SoapServerException' was thrown.Attempted to read or write protected memory. This is often an indication that other memory is corrupt. (This Post could save the time of people).

This error could occur due to memory leakage.so make sure that object is properly disposed .
Restarting IIS can resolve this issue but It may occur again If the memory leakge is not handled
 Verify memory leakage scenarios here

Updating lookup table in Project server 2010

Following is the code snippet for updating lookup table value in project server 2010

using PSLibrary = Microsoft.Office.Project.Server.Library;
using Updatelookup.WebSvcLookup;
using System.Net;
using System.Data;

namespace Updatelookup

class Program

static void Main(string[] args)

LookupTable tblLookup = new LookupTable();
tblLookup.Url = "pwaurl" + "/" + "_vti_bin/PSI/LookupTable.asmx";
NetworkCredential prjCdn = new NetworkCredential("user", "pwd", "domain");
tblLookup.Credentials = prjCdn;

AddToLookupTB(tblLookup, "Customer");


static void AddToLookupTB(LookupTable tblLookup, string TableName)

LookupTableDataSet lookupDs = new LookupTableDataSet();

//Get all the lookup table

//Get lookup table guid
lookupDs = tblLookup.ReadLookupTables("", false, 0);//
DataView dvLookup = new DataView(lookupDs.Tables["LookupTables"]);
dvLookup.RowFilter = "LT_Name = '" + TableName + "'";
DataTable lookupValueTB = new DataTable();

lookupValueTB = dvLookup.ToTable("LookupTable");
Guid LookupgId = new Guid(Convert.ToString(lookupValueTB.Rows[0]["LT_UID"]));

//Read lookup table dataset
Guid[] ltGuids = new Guid[] { LookupgId };
LookupTableDataSet LTCustomer = tblLookup.ReadLookupTablesByUids(ltGuids, false, 1033);
LookupTableDataSet.LookupTableTreesRow drLT_TREE = LTCustomer.LookupTableTrees.NewLookupTableTreesRow();

//Add new lookup value
drLT_TREE.LT_UID = LookupgId;
drLT_TREE.LT_STRUCT_UID = Guid.NewGuid();
drLT_TREE.LT_VALUE_TEXT = "Customer 3";
drLT_TREE.LT_VALUE_SORT_INDEX = (byte)PSLibrary.LookupTables.SortOrder.Descending;
( here I checked the orginal order of values in lookup table by Navigating server settings--> Lookup table-->Customer lookup table and made ensure that order given there and in mentioned in above code line is same .)
LookupTableDataSet newLTDs = LTCustomer.GetChanges() as LookupTableDataSet;

tblLookup.UpdateLookupTables(newLTDs, false, false, 1033);
tblLookup.CheckInLookupTables(ltGuids, false);


Wednesday, August 8, 2012

Enterprise Project Management:Project Site Approval Workflow in Project Server 2010 -- Part - II

i)To Deploy the project site workflow on PWA and configure Workflow Stages with PDP pages.
Get the deployment steps @Codeplex 
ii)To create project site workflow Read this post

Wednesday, July 18, 2012

OOB Table Of Contents WebPart To Show All Subsites

1)Edit the LevelStyle.xsl  file in In Top Level site\All Site Contents\Style libray to Show only sites and not the other libraries .

Edit the webpart properties as per the requirements

2)To Show All sites
Top Level site or the Site for which you need to display all subsites--Site actions -->Site settings -->Look and Feel-->Navigation -->Increase value

3)Add the TOC webpart (Edit Page-->Insert Webpart-->Select Content Rollup )
 4)Set the number of levels to one.(Edit Webpart-->Set Properties as below)
 This WebPart can be used as OOB Navigation WebPart through out the site.
This is one more useful blog most ,If more customization is required
Note -->TOC Webpart can dispaly navigation only in single site collection

Saturday, June 2, 2012

Project Site Provisioning In Project Server 2010

Project Server  synchronizes the permission and reset it back to  default permission , I need to change following settings in server settings for this reason.To break the permissions and assign custom site permissions  to groups Programmatically  follow as

PWA siteà Server  Settingsà Operational Policiesà Project Site Provisioning Setting àUncheck Project Permissions check box

Friday, May 11, 2012

Enterprise Project Management:Project Site Approval Workflow in Project Server 2010 -- Part - I

This workflow creates the project site for Basic project plan EPT when workflow task is approved.(This is the correction done over the Branching workflow provided with Project Server 2010 SDK).
Workflow task is created using PSWApprovalTask Content type in Project Server Workflow Task List.

1)Configure Visual Studio for Project Server activities.

New Project SharePointWorkflow -Create site workflow

And enter the url of PWA site

2)Map workflow stages activities to actual Workflow stages in PWA SharePoint Site

3)Enable  PSWEnableApprovalTask Content Type in Project Server Workflow Task List

4)Add the Web reference of Project.asmx and WssInterop.asmx to the Solution

5)Build and Deploy and Associate it Enterprise Project Type

For detailed description of  above steps please visit CodePlex and download the source and document

Friday, February 17, 2012

SharePoint Dialog Framework:Modal Popups With Dynamic Html

1)Make sure that ' this character dont appear in string in dynamic string as following.
tootipText=tootipText+" <a style=color:"+fontColor+" href=javascript:portal_openModalDialog("+EventUrl+"); >"+iEventCount +"."+this.toString()+"</a>";
$(tdEvent).attr("onclick", "CalendarEventsPopup('"+tootipText+"');");
function CalendarEventsPopup(result)

result = result.replace(/[(]/g,"('");
result = result.replace(/[)]/g,"')");

var div= "<div id=htmlDiv>
" + result + "</div>
html: document.getElementById('htmlDiv'),
title: "Events",
allowMaximize: false,
showClose: true,
autoSize: true,
dialogReturnValueCallback: Function.createDelegate(
null, portal_modalDialogClosedCallback)


function portal_modalDialogClosedCallback(result, value)

For details about the calendar customization ,I have uploaded source code @CodePlex

Saturday, February 11, 2012

SharePoint 2010 Social Features: Retrieve Noteboard data with SocialDataService.asmx

Noteboard is social data webpart for posting comments for any user activity.Read more..
To get Comments count on particular url
1)Add the jquery reference to masterpage
2)Invoke CountCommentsOnUrl webmethod of Social Data Webservice

<script type="text/javascript">
$(document).ready(function () {
var strURL = "http://server/Pages/PageWithNoteBoard.aspx?ID=3";
var CountMethod = '/_vti_bin/SocialDataService.asmx?op=CountCommentsOnUrl';

// var soapEnv = "<soap:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema'xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'><soap:Body><CountCommentsOnUrl xmlns='http://microsoft.com/webservices/SharePointPortalServer/SocialDataService'><url>+ strURL +</url></CountCommentsOnUrl></soap:Body></soap:Envelope>";

var soapEnv = "<soap:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema'
<CountCommentsOnUrl xmlns='http://microsoft.com/webservices/SharePointPortalServer/SocialDataService'>
<url>" + strURL + "</url>


url: CountMethod,
type: "POST",
async: true,
dataType: "xml",
data: soapEnv,
complete: proccessTagsAndNotes,
contentType: "text/xml; charset="utf-8""


function proccessTagsAndNotes(data, textStatus) {

var count = 0;
// count = $('CountCommentsOnUrlResponse', data).find('CountCommentsOnUrlResult').text();
count = $(data.responseText).find('CountCommentsOnUrlResult').text();

alert(' count' + count);


This code was working fine in my case but the link that helped me is here

Friday, February 3, 2012

Assign Custom Permission Levels in User Information List

1)To Add permissions in User Information List browse
2)right click on any user name link -->copy shortcut-->to get User Information List id
3)form the URL
_layouts/listedit.aspx?List=guid obtained as above
4)In Permission Settings add the Group having Custom Permission
5)Create the custom permission level as shown in following Image
6)you may need to add the custom permission levels for discussion board or to let the ad authenticated user modify there user info,in user information list
1)by default AD authenticated user don't have permissions to edit all the lists
so break the permissions for this list and create custom permissions for ad-authenticated user and add to User Information List
2)same is the case for discussion boards

Sunday, January 29, 2012

Silverlight Video and Image Carousal With SharePoint Client OM

Carousal/Video Slider using Silverlight Client Object Model.
This sample is for learning SharePoint client object model using Silverlight
This Includes
1)Fetch and Display SharePoint Data using Client OM
i)create class and identify the display properties
ii)set the properties with Client OM
iii)Display Video/Image/List Data on Tick Event of Timer and on Button Click
private void Tick(object o, EventArgs sender)
Application resource = Application.Current;
foreach (UIElement c in videoButtons.Children)
Button videoButton = c as Button;

videoButton.Style = (Style)resource.Resources["RoundedBtnActive"];
videoButton.Style = (Style)resource.Resources["RoundedBtn"];

if (currentImageIndex < bannerImages.Count - 1) { //Moves to Next Image/Video Data of List currentImageIndex++; } //Set the current image index to 0 if the current image is the last one in the collection else { currentImageIndex = 0; } for more details view BannerGallery.xaml.cs

2)Applying Sliding animation to Picture/Video summary with Silverlight
public Storyboard SlideImageEffect(UIElement controlToAnimate, double positionToMove)
DoubleAnimation da = new DoubleAnimation();
da.Duration = new Duration(timer.Interval); //TimeSpan.FromSeconds(1)
da.Duration = new Duration(TimeSpan.FromSeconds(1));

Storyboard sb = new Storyboard();
if (timer!=null)
sb.Duration = new Duration(timer.Interval);
sb.Duration = new Duration(TimeSpan.FromSeconds(1));
da.From = 560;
da.To = 0;

Storyboard.SetTarget(da, controlToAnimate);
Storyboard.SetTargetProperty(da, new PropertyPath("(UIElement.RenderTransform).(TranslateTransform.X)"));
//da.To = positionToMove;
return sb;

3)Applying Style and Positioning in Silverlight
i)write the style element in App.xaml(more details view app.xaml of source code)
ii)Style can be created in Expression Blend and added to app.xaml
and it can be accessed as below
Application resource = Application.Current;
videoButton.Style = (Style)resource.Resources["RoundedBtn"];
iv)for positioning different elements use grid control

I have uploaded the modified source code @CodePlex
This source code is extended from Silverlight SDK example

Monday, January 23, 2012

Debugging and Deploying Silverlight Applications In SharePoint

There are so many posts on Debugging and Deploying Silverlight Applications In SharePoint like

But few things I would like to add above posts
1)Select Sharepoint Project-->Tools -->Attach to Process -->select iexplorer.exe with Type Silverlight (In case if its showing script,silverlight in Attach Process box)
2)Project Reference of silverlight application in sharePoint Project through module element.

For more detail insight on SharePoint Integration with Silverlight
download training kit

Wednesday, January 18, 2012

Validation for New Form and Sharepoint:SPSecurityTrimmedControl

PreSaveAction is the Inbuilt function available in OOB NewForm.aspx of the Lists.It is already defined in core.js. It comes to rescue for fast customization of NewForm.aspx and OOB Webparts like Calendar .It also helps for validation for attachments in ListItem.
Following example helps to refresh the page when New event is added to Calendar.Shortly I will be writing the post on Calendar customization.

<script type="text/javascript">

function PreSaveAction()
window.parent.location.href = '_layouts/AccessDenied.aspx';
return true;
//Admins will be able to add the events from DayView of Calendar
<Sharepoint:SPSecurityTrimmedControl runat="server" PermissionsString="ManageWeb">
<script type="text/javascript">

function PreSaveAction()
window.parent.location.href = '..SitePages/Home.aspx';
return true;