Showing posts with label sharepoint 2010. Show all posts
Showing posts with label sharepoint 2010. Show all posts

Thursday, July 16, 2015

Shredded Storage in SharePoint 2013 Explained

  • Shredded Storage is related to management of large binary objects i.e BLOBS
  • Shredded Storage is both improves I/O and reduces compute utilization when making incremental changes to document or storing documents in SharePoint 2013.
  • Shredded storage is built upon cobalt i.e. file synchronization via soap of http introduced in SP 2010
  • Shredded Storage is enabled by default and cannot be disabled.
  • In SP 2010 , shredded storage was used for communication between client and web server but whereas database is concerned whole file was fetched and saved after changes this is changed and shredded storage BLOBS are stored in database .



FileReadChunkSize

SharePoint 2010 introduced a new FileReadChunkSize property as a control associated with the BLOB cache which enabled a server farm administrator to control the size of incremental reads when a client requested a file.

FileWriteChunkSize


In SharePoint 2013 a new property loosely related to FileReadChunkSize is provided to allow control of the size of a shredded BLOB. 

Monday, May 25, 2015

How to fix Last run time issue in SharePoint 2013 Timer job

one of issues which developers frequently face while running Timer Job is Last run time: shows as N/A

this happens after we run Timer job with run now option also



How to fix this ?

1. open the Services using services.msc in run window
2. Restart "SharePoint Timer Service" and "SharePoint Administration" services


now navigate back to Job definition ( Central administration ---> Monitoring -->  Job Definition) and open the timer job , you will be able to see Last run value.


Have a great day !!

Saturday, March 21, 2015

Get multiple List data across multiple sites using SPSiteDataQuery in Sharepoint 2013


Scenario:  you want to display data from multiple list spread across multiple site inside the site collection.


Solution : SPSiteDataQuery to query across the site with web scoped at SiteCollection.


Example to explain this : 

Set Up :  

I have one site collection with two subsites

1. ProjectSubsite1 with List named as IssueList


Now i want to aggregate these two list data and display in web part on top level site collection , this cannot be possible with SPQuery hence we will be using SPSiteDataQuery as shown below 

Properties to set
1. Query :  you need to mention your condition in caml query format 
2. List : you need to mention List Servertemplate Id , hence data will be fetched from those list types
3. ViewFields : no of fields to be fetched for diplay
4. Webs : here you have to mention Site Collection so that search is triggered across complete site collection.

once SPSiteDataQuery object is formed pass the object to method web.GetSiteData this return datatable 

using (SPSite site = new SPSite(SPContext.Current.Site.Url))
{
using (SPWeb web = site.OpenWeb())
{
SPSiteDataQuery query = new SPSiteDataQuery();

query.Lists = "<Lists ServerTemplate=\"100\" />";

query.Query
= "<Where><Eq><FieldRef Name='ContentType' /><Value Type='Text'>IssueCT</Value></Eq></Where>";

query.ViewFields = "<FieldRef Name='Title' />";

query.Webs = "<Webs Scope=\"SiteCollection\" />"; 

DataTable dt = web.GetSiteData(query);

}
 }


Limitation : SPSiteDataQuery will run only across particular site collection.








Saturday, February 7, 2015

Custom itemstyle.xsl for Content Query Webpart in SharePoint

While using Content Query Web Part its always best practice to use custom Item Style so here we will see how to create new templates in itemxsl style and change the reference in .webpart to custom item xsl style
1. Navigate to Style library –> XSL style sheets –> Itemstyle.xsl
And download the local copy .
2. ItemStyle.xsl contains different templates e.g. Default, NoImage, TitleOnly, TitleWithbackground etc,So to create custom ItemStyle.xsl , save ItemStyle.xsl as CustomItemStyle.xsl . Delete all the templates and add the new template with different name say HRDocs
<xsl:stylesheet
version=”1.0″
exclude-result-prefixes=”x d xsl msxsl cmswrt”
xmlns:x=”http://www.w3.org/2001/XMLSchema”
xmlns:d=”http://schemas.microsoft.com/sharepoint/dsp”
xmlns:cmswrt=”http://schemas.microsoft.com/WebParts/v3/Publishing/runtime”
xmlns:xsl=”http://www.w3.org/1999/XSL/Transform” xmlns:msxsl=”urn:schemas-microsoft-com:xslt”>
<xsl:output method=”html”/>
<xsl:param name=”ItemsHaveStreams”>
<xsl:value-of select=”‘False’” />
</xsl:param>
<xsl:param name=”FeedTitle” />
<xsl:param name=”WPPropertyBinding-Title” />
<xsl:variable name=”OnClickTargetAttribute” select=”string(‘javascript:this.target=&quot;_blank&quot;’)” />
<xsl:variable name=”ImageWidth” />
<xsl:variable name=”ImageHeight” />
<xsl:template name=”HRDocs” match=”Row[@Style=HRDocs]” mode=”itemstyle”>
<xsl:variable name=”SafeLinkUrl”>
<xsl:call-template name=”OuterTemplate.GetSafeLink”>
<xsl:with-param name=”UrlColumnName” select=”‘LinkUrl’”/>
</xsl:call-template>
</xsl:variable>
<xsl:variable name=”SafeImageUrl”>
<xsl:call-template name=”OuterTemplate.GetSafeStaticUrl”>
<xsl:with-param name=”UrlColumnName” select=”‘ImageUrl’”/>
</xsl:call-template>
</xsl:variable>
<xsl:variable name=”DisplayTitle”>
<xsl:call-template name=”OuterTemplate.GetTitle”>
<xsl:with-param name=”Title” select=”@Title”/>
<xsl:with-param name=”UrlColumnName” select=”‘LinkUrl’”/>
</xsl:call-template>
</xsl:variable>
<xsl:variable name=”LinkedInSafeImageUrl”>
<xsl:call-template name=”OuterTemplate.GetSafeLink”>
<xsl:with-param name=”UrlColumnName” select=”‘Linkedin’”/>
</xsl:call-template>
</xsl:variable>
<div>
<div>
<xsl:call-template name=”OuterTemplate.CallPresenceStatusIconTemplate”/> 
<div> 
<xsl:value-of select=”@documentname” />
</div>
<div>
<xsl:value-of select=”@docDescription” />
</div>
</div> </div> </xsl:template>
</xsl:stylesheet>
Things to take care while creating new template is to keep the same name for name and @style attributes( as below )
<xsl:template name=”HRDocs” match=”Row[@Style=HRDocs]“
and also add the <xsl:output method=”html”/> line  as added in above code to avoid the UI misalignement if any custom html is rendering null value.
3. Now upload this CustomItemStyle.xsl to same location ( Style Library –> XSL Style Sheets )
4. Now let’s make our CQWP to refer CustomItemStyle.xsl , open any page and add the CQWP and export the web part file which contains all the property tags , search for ItemXslLink
Which currently looks as
<property name=”ItemXslLink” type=”string”/>
Replace the above line with below
<property name=”ItemXslLink” type=”string”>/werkenbij/Style Library/XSL Style Sheets/CustomItemStyle.xsl</property>
Save the .webpart file as CustomCQWP.webpart and upload it to web part gallery [ Site Actions à Site Settings à Web parts (in Gallery)]
5. Add the web part on page , lets edit the web part to select the CustomItemStyle.xsl
Navigate to Presentation –>  Styles –>  Item Style and select CustomItemStyle.xsl from drop down.

That’s it guys your CQWP WITH CUSTOM Item style is ready to ship :)

Thursday, October 23, 2014

Programmatically Get List items inside the folders of SPList





How to search items inside the folders of list using caml query
many times while validating against multiple entries we have to query check , here we go to fetch all the  items inside the list including folders

you should use  spquery.ViewAttributes = "Scope=\"Recursive\"";  so that query searches in recursive way .
                             


full code
 SPList list = web.Lists["ListName"];


                                var querytext = "<View Scope='Recursive'><Where><Eq><FieldRef Name='UserName' /><Value Type='Text'>" + currentLogginUser.LoginName + "</Value></Eq></Where>";
                             
                                SPQuery spquery = new SPQuery();
                                spquery.Query = querytext;
                                spquery.ViewAttributes = "Scope=\"Recursive\""; 
                                var items = list.GetItems(spquery);


Thursday, September 18, 2014

Get Field value as text

I have seen many developers struggling to fetch text value from Multi line/ Choice column of sharepoint list or library , below is easiest way to achieve this

            SPSite site = SPContext.Current.Site;
            SPWeb web = site.OpenWeb();
            SPList declarationList = web.Lists["DeclarationContent"];
            SPListItem item = declarationList.Items[0];
            string content = item.Fields["declaration"].GetFieldValueAsText(item["declaration"]);


if u observe the above code item.Fields["declaration"] contains method GetFieldValueAsText
which accepts the value of column and it will convert the html or drop down /choice content into text value.

Happy Coding !!