Tuesday, July 2, 2013

Choti choti magar moti baatein (do's and don'ts) - SharePoint Tips

Hi Friends,

About Choti choti magar moti baatein(do's and don'ts). It’s a Hindi language catchphrase for caution about something, it’s got popular when Shaktimaan – An Indian Superhero started a series educating children about the right and wrong things. (In childhood we all enjoyed it, of course bunking from school  J )

In this brand new session we will discuss about SharePoint development do's and don'ts. It will improve the performance and usability of SharePoint applications.

We will also see SharePoint development tips, case studies, best practices and all about SharePoint world.

Everyone can do…
1)  Share a new topic
2) Start discussion
3) Suggest solutions
4) Nothing else……………


Amit Phule

Saturday, April 20, 2013

JQuery Selectors

JQuery is awesome, effective, powerful, rocking… I don’t have more word to say about JQuery.

In past I have posted some JQuery magic scripts, here I want to share some basic knowledge of JQuery selectors which will helps to target html tags.

jQuery offers a great engine for selecting html tags(elements) in the document which almost gives every filter option (tag name, attribute name, classes , properties etc.) for effective selection.

Here effective selection means, selection will not fail at any condition. Example: New html tags get added or in .Net server side controls id get change on each page load.


/* ########## Select HTML Tags ###########*/

// Get all tags by CSS class name
$(".ms-vb-user").css("display", "none");

// Get all div tags by CSS class name
$("div.ms-vb-user").css("display", "none");

// Get tag by id
var SelectedVal = $('#TDRightArea').text();

// Loop through all matching tags
$('a[href*=/_layouts/userdisp.aspx?ID=]').each(function () {
        var SelectedVal  = $(this).text();  
    });

//Get Parent Tag 
$('#TDRightArea').parent().html();


/* ########## Select and find in HTML Tags ###########*/

$('#TDRightArea').find('div.rightsubarea').each(function () { 
   $(this).css("color", "blue");
});


/* ########## Select .Net Controls ###########*/

// Get Radio Button List selected option
var SelectedVal = $('input[type=radio][id*=RBLLocation]:checked').val();

// Get TextBox entered text
var SelectedVal = $('input[type=text][id*=TxtLocation]').val();

// Get ListBox selected option
var SelectedVal = $("[id*='LBLocation'] option:selected").text();

// Get DropDown List selected option
var SelectedVal = $("[id*='DDLLocation'] option:selected").text();

// Get CheckBox List selected option
var SelectedVal = $('input[type=checkbox][id*=CBLLocation]:checked').next().text();

// Check CheckBox List option is checked, return true or false
var isChecked = $('input[type=checkbox][id*=CBLocation]').is(':checked');


/* ########## Select SharePoint Controls ###########*/

//Get PeopleEditor control value (SharePoint)
var SelectedVal = $("textarea[id*='PeopleEditorManager']").val();

More reference blogs:

http://api.jquery.com/category/selectors/
http://codylindley.com/jqueryselectors/
http://www.w3schools.com/jquery/jquery_ref_selectors.asp
http://www.w3schools.com/jquery/jquery_selectors.asp


ENJOY !!!

Sunday, February 17, 2013

Change Date Format of SharePoint Date Time Column


SharePoint 2010 provides a seamless, culture-specific experience that enables site owners to create sites in a specific language and configure the regional settings that are appropriate for those sites.

SharePoint Server 2010 uses the following types of regional settings: locale, time zone, sort order, calendar, and currency. You can specify the locale, sort order, time zone, and calendar settings on the Regional Settings page.

Change Date Format:
1) Go to "Site settings" from "Site Actions" Tab.
2) Under the "Site Administration" Section click on "Regional settings".
3) In "Locale" choice select desire option; example format DD/MM/YYYY you need to select "English (United Kingdom)".


Wednesday, January 2, 2013

Package the external DLL’s along with the SharePoint Solution (WSP)

Visual Studio 2010 by default does not include external DLL in the SharePoint Package (WSP). We need to add this DLL explicitly in the package.

1. Include external DLL in the SharePoint Project.

2. Include DLL using package manager.

3. Verify DLL is included in the WSP.
Enjoy !

Tuesday, June 5, 2012

Custom List Form in SharePoint Designer 2010 will not render if the list columns are more then 70 : Resolved

In SharePoint 2010, You can easily create custom list forms in SharePoint Designer, but some List Form will not render through error as “Unable to display this Web Part. To troubleshoot the problem, open this Web page in a Microsoft SharePoint Foundation-compatible HTML editor such as Microsoft SharePoint Designer. If the problem persists, contact your Web server administrator.”



Here is the resolution of problem. Follow below link.

http://social.technet.microsoft.com/Forums/en/sharepoint2010customization/thread/11a8b7c7-6bdd-485e-a8c6-083896cf6f83

Also I have copied the solution provide by Linda Chapman [MSFT]. Thanks Linda for your contribution.
Custom List Form in SharePoint Designer 2010 will not render if the list has a large number of columns.

Symptom
Custom List Form will not render if the list has a large number of columns. To reproduce this issue create a custom list and add 68 single line of text columns. The custom list form web part will not render and an error message such as this will occur in the browser:

Unable to display this Web Part. To troubleshoot the problem, open this Web page in a Microsoft SharePoint Foundation-compatible HTML editor such as Microsoft SharePoint Designer. If the problem persists, contact your Web server administrator.

Correlation ID:

For more information about custom list forms please refer to this article:

http://office.microsoft.com/en-us/sharepoint-designer-help/create-a-custom-list-form-using-sharepoint-designer-HA010378258.aspx

Cause

This occurs when a large XSL transforms happens in a single template.

Resolution
The issue can be resolved by breaking up the offending xsl template into smaller parts to avoid a large transform.

This example is for a New Form custom list form. The Edit Form is similar in template naming convention. Please refer to the end of the article for the template names of the various form modes.

1. Open the page that contains the none working custom list form web part.
2. Switch to code for this this workaround.
3. Search for the following string:


<xsl:call-template name="dvt_1.rowedit"/>


4. Copy this line paste it 3 to 5 times. The table structure and other components that makeup this template will be divided into the other copied templates. A general guideline is to have about 20 to 40 table rows per template. There is a fair amount of give with this recommendation.

5. Rename each pasted template by adding a number to the end of it.


<xsl:call-template name="dvt_1.rowedit"/>
<xsl:call-template name="dvt_1.rowedit2"/>
<xsl:call-template name="dvt_1.rowedit3"/>
<xsl:call-template name="dvt_1.rowedit4"/>
<xsl:call-template name="dvt_1.rowedit5"/>


6. Now, press the control key and click the dvt_1.rowedit. This will highlight the template's first line which is this:


<xsl:template name="dvt_1.rowedit">

7. Place the cursor infront of the less than sigh of <xsl:template name="dvt_1.rowedit">
8. Hold down Control + Shift and then press semicolon. This will highlight the entire template.
9. Go to the bottom of the template. The following should be the last line: </xsl:template>

9. Paste the following markup after the closing xsl temlate tag from stpe 9. In this example there are 5 different dvt_1.rowedit templates calls so we'll need 5 <xsl:template> elements to match.


<xsl:template name="dvt_1.rowedit">
<xsl:param name="Pos" select="position()"/>
<tr>
<td>
<table border="0" cellspacing="0" width="100%">

</table>
</td>
</tr>
</xsl:template>


10. Rename each of the templates pasted in step 9 to match the templates from step 5.


<xsl:template name="dvt_1.rowedit">

<xsl:template name="dvt_1.rowedit2"> 

11. Next, the conents of <xsl:template name="dvt_1.rowedit"> needs to be divided among the new templates, <xsl:template name="dvt_1.rowedit2">, <xsl:template name="dvt_1.rowedit3"> and so forth. The easiest way to do this is to start at the end of the template and cut out the last few table rows and paste them into the last template that was created. In this example that would be <xsl:template name="dvt_1.rowedit5">

The individual table rows that represent the various SharePoint fields are stored inside of the table HTML element and that valid HTML needs to be persisted into the new templates. A good way of ensure this happens is to find <table border="0" cellspacing="0" width="100%"> in <xsl:template name="dvt_1.rowedit"> and perform a Control + Shift + Semicolon to highlight the entire table.

Once this is done scroll down to the end of the table and carefully take entire table rows, <tr>, and their contents over to the last xsl template.

By default the following is the last chunk of markup in <xsl:template name="dvt_1.rowedit">:


<tr id="idAttachmentsRow">
<td nowrap="true" valign="top" class="ms-formlabel" width="20%">
<SharePoint:FieldLabel ControlMode="New" FieldName="Attachments" runat="server"/>
</td>
<td valign="top" class="ms-formbody" width="80%">
<SharePoint:FormField runat="server" id="AttachmentsField" ControlMode="New" FieldName="Attachments" __designer:bind="{ddwrt:DataBind('i','AttachmentsField','Value','ValueChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@Attachments')}"/>
<script>
var elm = document.getElementById('idAttachmentsTable');
if (elm == null || elm.rows.length == 0)
document.getElementById('idAttachmentsRow').style.display='none';
</script>
</td>
</tr>
<xsl:if test="$dvt_1_automode = '1'" ddwrt:cf_ignore="1">
<tr>
<td colspan="99" class="ms-vb">
<span ddwrt:amkeyfield="ID" ddwrt:amkeyvalue="ddwrt:EscapeDelims(string(@ID))" ddwrt:ammode="view"></span>
</td>
</tr>
</xsl:if>


This particular table row represents the attachment functionality inside of a custom list form. This should not be in multiple templates and makes sense to go to the last XSL template created.

All the other table rows, <tr>, should contain the various columns in your list. Again, start from the bottom and work up to keep this exercise easy.

Adjust these steps accordingly if custom HTML layout is used to display field controls.

12. Finally, here is an example of the finished product. Each template only contains 1 column and the attachment functionality in the last xsl template. Also, only <xsl:template name="dvt_1.rowedit"> and <xsl:template name="dvt_1.rowedit2"> were included.


<xsl:template name="dvt_1.rowedit">
<xsl:param name="Pos" select="position()"/>
<tr>
<td>
<table border="0" cellspacing="0" width="100%">
<tr>
<td width="190px" valign="top" class="ms-formlabel">
<H3 class="ms-standardheader">
<nobr>Title<span class="ms-formvalidation"> *</span>
</nobr>
</H3>
</td>
<td width="400px" valign="top" class="ms-formbody">
<SharePoint:FormField runat="server" id="ff1{$Pos}" ControlMode="New" FieldName="Title" __designer:bind="{ddwrt:DataBind('i',concat('ff1',$Pos),'Value','ValueChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@Title')}"/>
<SharePoint:FieldDescription runat="server" id="ff1description{$Pos}" FieldName="Title" ControlMode="New"/>
</td>
</tr>
</table>
</td>
</tr>
</xsl:template>

<xsl:template name="dvt_1.rowedit5">
<xsl:param name="Pos" select="position()"/>
<tr>
<td>
<table border="0" cellspacing="0" width="100%">
<tr>
<td width="190px" valign="top" class="ms-formlabel">
<H3 class="ms-standardheader">
<nobr>NewColumn90</nobr>
</H3>
</td>
<td width="400px" valign="top" class="ms-formbody">
<SharePoint:FormField runat="server" id="ff91{$Pos}" ControlMode="New" FieldName="NewColumn90" __designer:bind="{ddwrt:DataBind('i',concat('ff91',$Pos),'Value','ValueChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@NewColumn90')}"/>
<SharePoint:FieldDescription runat="server" id="ff91description{$Pos}" FieldName="NewColumn90" ControlMode="New"/>
</td>
</tr>
<tr id="idAttachmentsRow">
<td nowrap="true" valign="top" class="ms-formlabel" width="20%">
<SharePoint:FieldLabel ControlMode="New" FieldName="Attachments" runat="server"/>
</td>
<td valign="top" class="ms-formbody" width="80%">
<SharePoint:FormField runat="server" id="AttachmentsField" ControlMode="New" FieldName="Attachments" __designer:bind="{ddwrt:DataBind('i','AttachmentsField','Value','ValueChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@Attachments')}"/>
<script>
var elm = document.getElementById('idAttachmentsTable');
if (elm == null || elm.rows.length == 0)
document.getElementById('idAttachmentsRow').style.display=&apos;none&apos;;
</script>
</td>
</tr>
<xsl:if test="$dvt_1_automode = '1'" ddwrt:cf_ignore="1">
<tr>
<td colspan="99" class="ms-vb">
<span ddwrt:amkeyfield="ID" ddwrt:amkeyvalue="ddwrt:EscapeDelims(string(@ID))" ddwrt:ammode="view"></span>
</td>
</tr>
</xsl:if>
</table>
</td>
</tr>
</xsl:template>

Supplemental Information

The following are the template names for Edit Forms and Display Forms. The same concept applies to these as the New Form templates.

Display Form:


<xsl:call-template name="dvt_1.rowview"/> and <xsl:template name="dvt_1.rowview">


Edit Form, which is the same as New Form:


<xsl:call-template name="dvt_1.rowedit"/> and <xsl:template name="dvt_1.rowedit">

Enjoy !!!

Tuesday, May 22, 2012

SharePoint 2010 Capacity Planning

This article provides an overview of how to effectively plan and manage the capacity of SharePoint 2010 environments. This article also describes how to maintain a good understanding of the capacity needs and capabilities of your deployment, by analysis of performance and volume data.

Capacity management is an ongoing process, You need to plan for growth and change, so that your SharePoint Server 2010–based environment can continue to deliver an effective business solution.
The capacity management model includes additional steps to help you validate and tune the initial architecture, and provides a feedback loop for re-planning and optimizing the production environment until it can support design goals with optimal choices of hardware, topology, and configuration.

# The following specialized terms are used in SharePoint 2010 capacity management:

RPS:   Requests per second. The number of requests received by a farm or server in one second.
Peak hours:   The time or times during the day when load on the farm is at its maximum.
Peak load :  The average maximum daily load on the farm, measured in RPS.
Load spike:   Transient load peaks that fall outside usual peak hours. These can be caused by unplanned increases in user traffic, decreased farm throughput because of administrative operations, or combinations of such factors.
Scale up:   To scale up means to add resources such as processors or memory to a server.
Scale out :  To scale out means to add more servers to a farm.
Throughput:  Throughput is defined as the number of concurrent requests that a server or server farm can process.


# Limits and boundaries:
Web application limits

Content database size ( general usage scenarios)
200 GB per content database
Content database items
60 million items including documents and list items
Site collections per content database
2,000 recommended
5,000 maximum
Web site
250,000 per site collection
Site collection size
Maximum size of the content database
Web parts
25 per wiki or Web part page

List and library limits
The following table lists the recommended guidelines for lists and libraries.
List row size8,000 bytes per row
File sizeThe default maximum file size is 50 MB and  Maximum 2 GB.
Documents30,000,000 per library
Major versions400000
Items30,000,000 per list
List view lookup threshold8 join operations per query
List view threshold5000
List view threshold for auditors and administrators20000
Subsite2,000 per site view

Column limits
SharePoint Server 2010 data is stored in SQL Server tables.

Single line of text28 bytes
Multiple Lines of Text28 bytes
Choice28 bytes
Number12 bytes
Date and Time12 bytes
Lookup4 bytes
Yes / No5 bytes
Person or group4 bytes
Hyperlink or picture56 bytes
Calculated28 bytes

Blog limits
The following table lists the recommended guidelines for blogs.

Blog posts5,000 per site
Comments1,000 per post


Groups limits 

Number of SharePoint groups a user can belong to5000
Users in a site collection2 million per site collection
Active Directory Principles/Users in a SharePoint group5,000 per SharePoint group
SharePoint groups10,000 per site collection


References:
2.       Column limits

Wednesday, April 25, 2012

Display Item Attachments in SharePoint List View

It is very easy to display list item attachments
in List View and also manipulate the display of attachment, like if attachment is
image, we can display image not just a link.
1. Open List View in SharePoint Desinger
2. Add new column titled "Attachments".
3. Select TD tag of New column.
4. Replace selected code with below code.


 <td id="ItemAttchment" class="ms-vb">
          <xsl:element name="SharePoint:AttachmentsField">
          <xsl:attribute name="runat">server</xsl:attribute>
                    <xsl:attribute name="FieldName">Attachments</xsl:attribute>
          <xsl:attribute name="ControlMode">Display</xsl:attribute>
          <xsl:attribute name="Visible">true</xsl:attribute>
          <xsl:attribute name="ItemId">
              <xsl:value-of select="@ID"/>
          </xsl:attribute>
          </xsl:element>
</td>


5. View with Attachments