Author Archive

Adding expand/collapse using XSLT in SharePoint 2013

June 18, 2015 Leave a comment


There is a scenario to add expand/collapse functionality in the Business Data Connectivity Webpart

which pulls the data from SQL.

In the BDC webpart we can customize the look & feel using XSL Editor.

In XSL create your own template as given,

<xsl:template name=”CustomRowview”>
<tr id=”group0{generate-id()}”>
<td class=”ms-gb” colspan=”99″ style=”width:100%”>
               <a onclick=”javascript:ExpGroupBy(this);return false;” href=”javascript:”>
               <img border=”0″ name=”expand” alt=”expand” src=”/_layouts/images/plus.gif”/>
               <xsl:value-of select=”@Last_Name” disable-output-escaping=”yes”/>,
               <xsl:value-of select=”@First_Name” disable-output-escaping=”yes”/>

<tr style=”display:none;”>
<td style=”width: 50%; height: 20px”>

<td><span style=”margin-left:5px;”>Item1:</span>
<xsl:value-of select=”@Item1Value” disable-output-escaping=”yes” /></td>


<td><span style=”margin-left:5px;”>Item2:</span>
<xsl:value-of select=”@Item2Value” disable-output-escaping=”yes” /></td>








ExpGroupBy(this) – internal javascript function called for expand/collapse.

Then you can call your newly created custom template in place of default template as given,

<xsl:for-each select=”$Rows”>
<xsl:if test=”position() &gt;= $FirstRow and position() &lt;= $LastRow”>
<xsl:call-template name=”CustomRowview” />



Custom ASPX page in SharePoint 2013

June 18, 2015 Leave a comment

Hi All,

We might be having a scenario to create custom ASPX Wiki page in SharePoint without inheriting SharePoint branding.In this case sp.js reference to be added explicitly in order to connect to SharePoint Lists etc. Below are the files to be referred in the HEAD section of ASPX page,so that you can make use of clientcontext and other SP.JS functionalities.

<script type=”text/javascript” src=”/_layouts/sp.init.js”></script>
<script src=”/_layouts/1033/init.js” type=”text/javascript”></script>
<script src=”/_layouts/MicrosoftAjax.js” type=”text/javascript”></script>
<script src=”/_layouts/sp.core.js” type=”text/javascript”></script>
<script src=”/_layouts/sp.runtime.js” type=”text/javascript”></script>
<script src=”/_layouts/SP.UI.Dialog.js” type=”text/javascript”></script>
<script src=”/_layouts/sp.js” type=”text/javascript”></script>
<script type=”text/javascript” src=”/_layouts/ScriptResx.ashx?name=sp.res&culture=en-us”></script> 

Configuration Values in SharePoint 2010 Timer Job

Hi All,

                      1. When we develop custom timer job in SharePoint 2010 most of the time we might need to store some config

values    which    can  be utilized while activating the feature or during the execution of the timer job.

                      2. Some of us may think about the use of config list and fetch the data from there when we move the package

from dev.  environment to other environment we should also carry over the configuration list along with site url where the

config list resides.

                      3. In order to remove from these kind of pain SharePoint is having an awesome feature called Property bag .

MSDN reference contains Property bag implementation in details

Below is Powershell script which can be used to create property bag values


$snapin = Get-PSSnapin | Where-Object {$_.Name -eq ‘Microsoft.SharePoint.Powershell’}
if ($snapin -eq $null) {
Write-Output “Loading SharePoint Powershell Snapin”
Add-PSSnapin “Microsoft.SharePoint.Powershell”

# —————————————————–
Write-Output “Task initialized…”

$weburl= “http://../sites/test/Implemetnation”
$url= [System.Web.HttpUtility]::UrlDecode($weburl)
$site = New-Object Microsoft.SharePoint.SPSite($url)
$rootWeb = $site.RootWeb

Write-Host -foregroundcolor Green “The current Site”$rootWeb

$PropertyKey = “siteUrl”

$webvalue= “/Implemetnation”
$PropertyValue = [System.Web.HttpUtility]::UrlDecode($webvalue)


$rootWeb.AllowUnsafeUpdates = $true;
$Currentvalue = $rootWeb.Properties[$PropertyKey]
Write-Host -foregroundcolor Green “The current value of the property bag is “$Currentvalue

if (!$rootWeb.Properties.ContainsKey($PropertyKey))
$rootWeb.Properties.Add($PropertyKey, $PropertyValue);
$rootWeb.Properties[$PropertyKey] = $PropertyValue;

$rootWeb.AllowUnsafeUpdates = $false;

$UpdatedValue =  $rootWeb.Properties[$PropertyKey]
Write-Host -foregroundcolor Green “Value of the property bag is updated with ” $UpdatedValue
if ($rootWeb -ne $null)

If ($site -ne $null)

Write-Host -foregroundcolor Green “Script has finished executing ”
Write-Output “Task completed…”



Xenu sleuth for capturing hard-coded url

March 16, 2014 Comments off

Recently when i was working in a SharePoint migration 2007 to 2010 project faced a challenging scenario as given.

Our Sharepoint 2007 application contains hard-coded url in many entities like Lists,WebPart Pages etc. During the course of migration we need to update all the hard-coded url with the updated relative url based on the new environment.

1) Just to kick start we have decided to find out the pages contains the Content Editor WebPart which have

reference to the old url. There is a powershell script we have customized based on our requirement to get the list of pages with

CEWP which meets our criteria.

2) Then we have developed a custom utility to replace the hard coded url with the updated url based on the result

obtained from step 1.

3)After all find & replace stuff we decided to ensure that there will be no reference to the hard coded urls in anywhere in the SharePoint application.

For this task there is a utility called “Xenu sleuth”

It’s open tool that can be downloaded and installed in order to use the same. The instruction on how to use the tool also available in the above url. One  drawback what we have faced is we are not able to get the Referrer of the hard coded url (i.e. the page in which the hard coded url is referred.)

But it’s a noteworthy tool in order to verify  hard coded Url during the course of migration.

Categories: Sharepoint

FAST Search in Sharepoint 2010

Hi All,

                     Recently had a scenario to explore about the Sharepoint 2010 FAST search.Let me state out the key steps to be done for the people who are new to

FAST search development.

                     In Sharepoint we can use the FAST search in either of the way as given

                               1. Using Sharepoint server object model

                              2. Using Sharepoint OOB Search.asmx webservice

                 Before proceeding we need to select a query lanaguage for the FAST search. It can ssupport

                                  a)  Keyword Query Langage (KQL)

                                   b) FAST Query Language (FQL)

              KQL is pretty straight forward when compared with FQL whereas it is having below limitation. Even though we can able to retrive the data based on particular date,KQL doesn’t support the search based on datetime range.This is one among the key objective when developer prefer FQL to KQL.

Steps Involved:

FAST installation &  configuration beyond the scope of this article.

i)  Create the Content Source

ii) Create Content types

  • There are scenario where we might requires to create a content type which has to be  available across sitecollections.
  • For this we need to create a dedicated sitecollection to act as ContentType Hub. This blog well addressed on this topic
  • Once the content type hub is created as in above step,we can create the content types & site columns.If there aremore no. of content types & site columns to be created we can make use of Powershell script to reduce the amunt of deployment time.
  • Below the powershell script which will query the simple XML file structure for list of content  types and associated site columns to be created.

iii) Craete Crawled properties

  • Once the sharepoint list or document library structures are created add some data into that. After this start the full crawlingfrom FAST search admin in Central Administration.
  • After the completion of the full crawl, the crawled properties will be created automatically by the Sharepoint,also it will be like                                            ows_{FIELD_INTERNALNAME}

iv) Create Managed Properties

  • Managed properties are the one which will be used like key search term while querying using Sharepoint Search.
  • When creating the managed property from central admin we need to make sure the Queryable property is selected, else it will not give any search result when you search using the managed property.

v) Start to search

           1) Using Sharepoint server object model

  • Once the initial setups are done as per the above steps, here we need to choose the language
  • For both KQL & FQL we can use KeyWordQuery class under the namespace Microsoft.Office.Server.Search.Query .For FQL need to  set  EnableFQL  property is true.

          2) Using Search.asmx

vi)FAST Search Tool

Add Webpart in sharepoint wiki page

June 22, 2013 1 comment

Recently one of my friend asked about adding a sharepoint document library webpart in to

a Wiki page. Wiki page still allows you to add a webpart by Edit page but the list of webparts are limited

when compared with Webpart Page. As a workaround we have created a new webpart page and added the

document library wbpart.Then using Sharepoint designer opened the webpart page and copy the Webpart

content and pasted into Wiki Page.

While doing so you need to make sure there are pre-requisite sharepoint specific javascript file

should be loaded for the webpart to function properly.

<script type=”text/javascript” src=”//”>
<script type=”text/javascript” src=”_layouts/sp.runtime.js”></script>
<script type=”text/javascript” src=”_layouts/sp.js”></script>
<script type=”text/javascript”>
// Continue your program flow here.

Read outlook eml file without outlook API

March 2, 2013 2 comments

This post addresses how to  extract From,To,Subject and message body content from  *.eml file. Initialy i have tried my hand in using

Outlook API but results intermittent security exception while instatntiating the object. After much exploration in the web came to know about

the COM API called Collaborative Data Object model it can be located under Add Reference in VisualStudio under COM section namely

Microsoft CDO For Windows 2000 Library.

Below the code snippet where *.eml file name will be passed in turn returns object of type CDO.Message.

protected CDO.Message ReadMessage(String emlFileName)
            CDO.Message msg = null;
                msg = new CDO.MessageClass();
                ADODB.Stream stream = new ADODB.StreamClass();
                stream.Open(Type.Missing, ADODB.ConnectModeEnum.adModeUnknown, ADODB.StreamOpenOptionsEnum.adOpenStreamUnspecified, String.Empty, String.Empty);
                msg.DataSource.OpenObject(stream, “_Stream”);
            catch (Exception ex)
            { }
            return msg;
Note:  using Outlook Express  you can save the message as *.eml file.