Thursday, October 3, 2013

SharePoint 2010 Custom Display Form Comments History not showing

In this post I will explain one of my experience when creating SharePoint custom list display form.

For one list we have version history enabled with one field called “Comments” as multiline with append text enabled.

After creating the custom form the comments will display as

<xsl: select=”@Comments” value-of disable-output-escaping=”yes” />

and comments history was not visible.

After replacing the above line with

<SharePoint:AppendOnlyHistory runat=”server” ControlMode=”Display” FieldName=”Comments” ItemId=”{@ID}”  />
All details are showing perfectly.

Export and Import SharePoint Designer 2010 List Workflow

In this post I will explain how to export and import SharePoint 2010 designer list workflow from one site/list to another using simple approach.

1.      Open SharePoint Designer 2010, Navigate to the workflow section.

2.      Then click on “Export to Visio”. Save the file as CopyListItems.vwi or any suitable name.

3.      Then create a new list with same schema on same site or another site collection.

4.      In SharePoint 2010 there is no direct way to import the previously exported workflow into the newly created list.

5.      Navigate to the newly created list and create list workflow without any workflow steps or empty. Then click on “Save” and “Publish” the newly created workflow say BlankWF.

6.      Then Click on “Export to Visio” and save this BlankWF.vwi or any suitable name.

7.      Rename both vwi files as .zip i.e CopyListItems.zip and BlankWF.zip.

8.      Replace the “workflow.xoml.wfconfig.xml” file from BlankWF.zip into CopyListItems.zip

9.       Remove .zip extension to .vwi and “Import from visio” and select CopyListItems.vwi.

Saturday, August 10, 2013

Apply style to welcome menu text in SharePoint 2010 master page



In this post I will explain the various styles applied to welcome menu text

.s4-trc-container-menu
This class is applied to DIV tag that binds the welcome text

.s4-trc-container-menu {
    float: left! important;
    margin: 12px 3px!important;
}

.ms-SPLink
This class is applied to SPAN tag
.ms-SPLink {
    color: #32B0A4!important;
    font-family: 'Tahoma’, ‘Lucida Grande’, Verdana,Arial,sans-serif! important;
    font-size: 0.8em!important;
}

.s4-trc-container-menu .ms-SPLink
.s4-trc-container .ms-SPLink {
    display: inline!important;
    vertical-align: middle!important;
}
.ms-SpLinkButtonInActive
.ms-SpLinkButtonInActive, .ms-SpLinkButtonActive {
    padding: 1px 1px 1px 3px!important;
}
.ms-HoverCellInActive, .ms-SpLinkButtonInActive {
    background-color: transparent!important;
    border: medium none!important;
    color: #3F3F3F!important;
    margin: 1px!important;
    vertical-align: top!important;
}

.ms-welcomeMenu
.ms-welcomeMenu {
    border: 1px solid transparent!important;
    display: inline-block!important;
    font-family: Verdana,sans-serif!important;
    font-size: 1em!important;
    margin: 0 3px!important;
    padding: 2px 5px 3px!important;
}

.ms-welcomeMenu  a:link
.ms-welcomeMenu  a:link {
Color:#fff!important;
}
.ms-welcomeMenu a:hover
.ms-welcomeMenu  a:hover {
text-decoration:none!important;
}
.ms-viewselector-arrow
.ms-viewselector-arrow {
    vertical-align: middle;
}

Now we will add current login user photo nearby the welcome menu text. In order to do so add the below register tag in the master page

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

Then find the div tag with class “s4-trc-container-menu” and add the below line in next line after this class 

<SPSWC:ProfilePropertyImage PropertyName="PictureUrl" style="float: left; height: 20px;" ShowPlaceholder="true" id="PictureUrlImage" runat="server"/>
text-decoration:nonetext-decoration:nonetext-decoration:nonetext-decoration:none}

Monday, July 15, 2013

Fixed width SharePoint 2010 master page



In this article we will add CSS that can align the SharePoint 2010 master page to center of the web page.

In the Master page search for s4-workspace and add the s4-nosetwidth class to that div shown below

<div id="s4-workspace" class="s4-nosetwidth">
</div>

Then add the below CSS in the style sheet file

body{
overflow:auto!important;
}
form
{
width:1024px!important;
margin-left:auto!important;
margin-right:auto!important;
}
body #s4-workspace {
    left: 0!important;
     overflow: visible !important;
    position: relative!important;
}

Saturday, June 22, 2013

SharePoint 2010 Custom Master page Design and Register custom CSS



In this article, I will help you to understand how to design master page and register custom CSS. SharePoint 2010 comes with OOB Master Pages; v4.master page is the default master in SharePoint 2010. Master pages are basically used to give consistent look throughout the site as well as it includes common elements throughout the site.
We will be using copy of v4.master page to design the custom master page. Firstly I will explain how to register custom CSS in master page; so open your site in SharePoint 2010 Designer
Click on the Master page from left menu and copy v4.master page and rename it

Next we need to overrides the default core4.css applied to the newly created master page (BrandingTeamsite.master); click the All files from left menu and open the Style library. Right click on the Style library and add new CSS file.
Open the BrandingTeamsite.master page and search the head tag. Add the below link in the master page
            <SharePoint:CSSRegistration name="/Style Library/Teamsite.css" After="corev4.css" runat="server"/>
Or
            <SharePoint:CSSRegistration name="<%$SPUrl:~SiteCollection/Style Library/Teamsite.css%>"  After="corev4.css" runat="server"/>

In the future article we will focus on how to apply css to master page.

Tuesday, February 12, 2013

Avoid memory leak issue in custom developed code

Many times we are involved in developing public SharePoint site and customer complaints about site loading slowly. This could be to due memory leakage problem in custom functionality integrated on the SharePoint site.

We all know that SharePoint objects can occupy huge memory. Thus SPDisposeCheck is nice tool that recognize where we forgot to dispose SharePoint objects and helps in avoiding any memory leaks in custom code.

Below is the link to download this tool

Saturday, February 2, 2013

Fetch User Profile Property for logged IN user using SharePoint Object Model

In this post, I will explain how to fetch user profile property for logged IN user using SharePoint object model.

To use user profile API we need to have reference to the Microsoft.Office.Server.UserProfiles. You can refer below code snippet to fetch user profile property

Code snippet
try
   {
     string department;
     string email;
     SPServiceContext serviceContext = SPServiceContext.GetContext(SPContext.Current.Site);
 
     UserProfileManager upm = new UserProfileManager(serviceContext);
 
     String domainuserName = String.Format(SPContext.Current.Web.CurrentUser.LoginName);
 
     UserProfile up = upm.GetUserProfile(domainuserName);
 
     department = up.GetProfileValueCollection("Department").Value == null ? String.Empty : (String)up.GetProfileValueCollection("Department").Value;
 
     email = up.GetProfileValueCollection("WorkEmail").Value == null ? String.Empty : (String)up.GetProfileValueCollection("WorkEmail").Value;
 
     lbldepartment.Text = department;
     lblemail.Text= email;
    }
    catch (Exception ex)
      {
        lblError.Text = ex.Message;
      }