Archive for November, 2014

Introduction

The Distributed Cache service provides caching features in SharePoint Server 2013. The microblog features and feeds rely on the Distributed Cache to store data for very fast retrieval across all entities. The Distributed Cache service is built on Windows Server AppFabric, which implements the AppFabric Caching service. Windows Server AppFabric installs with the prerequisites for SharePoint Server 2013. The Distributed Cache service provides in-memory caching services to several features in SharePoint Server 2013. Some of the features that use the Distributed Cache service include:

  • Newsfeeds
  • Authentication
  • OneNote client access
  • Security Trimming
  • Page load performance

In SharePoint Server 2013, there are several caches that exist, all of which depend on the Distributed Cache service.

Different caches that depend on the Distributed Cache service as indicated in the following table:

Name Cache Name Description
Login Token Cache DistributedLogonTokenCache
Feed Cache DistributedActivityFeedCache This cache stores activities and conversations for use by the feeds on a user’s My Site.
Last Modified Time Cache DistributedActivityFeedLMTCache This cache stores time stamp information for all Feed Cache entities.
OneNote Throttling DistributedBouncerCache
Access Cache DistributedAccessCache
Search Query Web Part DistributedSearchCache
Security Trimming Cache DistributedSecurityTrimmingCache
App Token Cache DistributedServerToAppServerAccessTokenCache
View State Cache DistributedViewStateCache
Default Cache DistributedDefaultCache This cache can be used by any feature.

The microblog features and feeds rely on the following two caches: the Last Modified Time Cache and the Feed Cache.

  • Feed Cache: The Feed Cache stores recent activities and recent conversations for all entities.
  • Last Modified Time Cache: The Last Modified Time Cache is used to determine the last modified time for all items in the Feed Cache.

Source: Overview of microblog features, feeds, and the Distributed Cache service in SharePoint Server 2013.

Useful API reference of the most frequently used types and objects implemented in .NET object model and at least one client programming model. .NET client-side object model (CSOM), JavaScript object model (JSOM), and/or REST.

CSOM  JSOM and REST API index

CSOM  JSOM and REST API index part 2

CSOM  JSOM and REST API index part 3

CSOM  JSOM and REST API index part 4

Ref: SharePoint 2013 .NET Server, CSOM, JSOM, and REST API index

Introduction

When you create a new web part page in SharePoint, its left navigation column becomes empty. The reason for this is that the left side navigation is defined in the Master Page using the “PlaceHolderLeftNavBar” content place holder and templates for Web Part Pages shipped with SharePoint and overrides this content place holder and deletes its content, thus displaying empty left navigation.

The solution for this is to change the page so it will not override the menu place holder, but inherit it from the Master Page. The place holders we are interested in are:

Solution

  1. There is this tag that needs to be deleted or commented (this one hides the left nav):

    tag for deleted or commented

  2. Delete only this tag since this is what overrides the default nav coming from the master page.

    contentplaceholder

  3. Leave this tag as it is, if this is deleted (as said in other posts) it leaves a blank row on top of the left nav which is not what you would want.

    content place holder

  4. Save the file.

You will get a warning saying you are about to customize the page. Just go ahead and open that web part again. It should have that good left navigation.

Cause

This is a very common issue faced by 9 out of 10 SharePoint developers. The custom site Logo is not reflected on the Web Part Page and hence the default logo is seen as shown in the screenshot:

Home Page

sharepoint home page

NewTestPage (WebPartPage)

new test page in sharepoint
Solution

  1. Go to the Web part (NewTestPage) page.
  2. Click on the “Page” tab at the top, click on the “Title Bar Properties” at the right (in the ribbon).

    page title bar

  3. In the Image Link section on the right, paste in the image URL:

    image url

  4. Click OK.

Out Page: Web part Page

new test page

Introduction

In this blog we explore to retrieve large number of items with a better performance we can either user SPQuery or PortalSiteMapProvider Class. Read more with examples. Retrieving large number of items from SharePoint List.

If you have to retrieve a large number of items and also need a better performance then you should use one of the method below:

  • Using SPQuery
  • Using PortalSiteMapProvide

Let’s see the example for both the method

SPQuery

  1. using (SPSite CurrSite = new SPSite(SPContext.Current.Web.Url))
  2. {
  3.    using (SPWeb CurrWeb = CurrSite.OpenWeb())
  4.    {
  5.        SPQuery curQry = new SPQuery();
  6.        curQry.Query = “<Where><Eq><FieldRef Name=’Dept’/> <Value Type=’Text’>Sharepoint</Value></Eq></Where>”;
  7.        curQry.RowLimit = 100;
  8.        SPList curList = CurrWeb.Lists[“Dept”];
  9.        SPListItemCollection curItems = curList.GetItems(curQry);
  10.        foreach (SPListItem curItem in curItems)
  11.        {
  12.            string ResultTitle = curItem[“Title”].ToString();
  13.        }
  14.    }
  15. }

PortalSiteMapProvide

The Class includes a method called GetCachedListItemsByQuery that retrieves data from a list based on an SPQuery object that is provided as a parameter to the method call.

The method then looks in its cache to see if the items already exist. If they do, the method returns the cached results, and if not, it queries the list , store the results in cache and returns them from the method call.

  1. //Get Current Web
  2. SPWeb curWeb = SPControl. GetContextWeb(HttpContext.Current);
  3. //Create the Query
  4. SPQuery curQry = new SPQuery();
  5. curQry.Query = “<Where><Eq><FieldRef Name=\’Category\’/><Value Type=\’Text\’> Sharepoint </Value></Eq></Where>” ;
  6. //Get Portal Map Provider
  7. Portal SiteMapProvider ps = PortalSiteMapProvider.WebSiteMapProvider;
  8. PortalWebSiteMapNode pNode = TryCast (ps.FindSiteMapNode (curWeb. ServerRelativeUrl), PortalWebSiteMapNode);
  9. //Get the items
  10. Pltems = ps.GetCachedListItemsByQuery (pNode, “Dept”, curQry, curWeb);
  11. //Enumerate all resulting Items
  12. foreach(PortalListItemSiteMapNode curItem in pItems)
  13. {
  14.    string ResultItemTitle = curItem[“Title”]. ToString();
  15. }

Using the keyboard shortcut is always effective that using the mouse, especially if the graphical designer of the page moved and you are unaware of that. Keyboard shortcuts can help you find what you want and where you want to go.

To use the keyboard shortcut combinations, you must press several keys at the same time. After pressing certain key combination you must release the keys before pressing another.

You can see which key is assigned to the options by pressing key Alt+ tab.

 Shortcuts are shown in below screen grabs displayed as in black box.

 

For example

Summary

In this blog, we have an overview on keyboard shortcut keys for SharePoint 2013.

Introduction

_spPageContextInfo variable provides few properties which will be useful in JavaScript and client object model code.

_spPageContextInfo is a  JavaScript/jquery context variable, which will rendered for each SharePoint page. _spPageContextInfo holds few proprieties which will be useful in JavaScript/jquery and client object model code. If you want to know the properties of _spPageContextInfo, go to view page source and find text with “_spPageContextInfo”.

When It will be useful

When we are making any ajax calls, we might need the server URL dynamically. In this case we can use _spPageContextInfo.siteAbsoluteUrl property.

If you want to know the current SharePoint List GUID, use _spPageContextInfo.pageListId.

Even it has more properties also(which are self explanatory). We can use them according to the requirements.

Sample Code

  1. $.ajax({
  2.          beforeSend: function (request) {
  3.             request.setRequestHeader(“Accept”“application/json;odata=verbose;charset=utf-8”);
  4.       },
  5.       url: _spPageContextInfo.siteAbsoluteUrl +“/_api/search/query?querytext='” + request.term + “*’&sourceid=’b09a7990-05ea-4af9-81ef-edfab16c4e31’&rowlimit=’20’&selectproperties=’FirstName,AccountName,PictureURL,SipAddress,PreferredName,Country,City'”,
  6.                 dataType: “json”,
  7.                 success: function (data) {
  8.                     response($.map(data.d.query.PrimaryQueryResult.RelevantResults.Table.Rows.results, function (item) {
  9.                         return {
  10.                             fields: getFields(item.Cells.results)
  11.                         }
  12.                     }));
  13.                 },
  14.                 error: function (data) {
  15.                     alert(‘search error’);
  16.                 }
  17.             });
  18. _spPageContextInfo Object Properties found for SharePoint 2013 application:
  19. alertsEnabled: false
  20. allowSilverlightPrompt :“True”
  21. clientServerTimeDelta :-8980
  22. crossDomainPhotosEnabled: false
  23. currentCultureName: “en-US”
  24. currentLanguage: 1033
  25. currentUICultureName: “en-US”
  26. layoutsUrl: “_layouts/15”
  27. pageListId:  “{df5e2d45-ad0b-4608-a813-ded6a97511db}”
  28. pagePersonalizationScope:  1
  29. serverRequestPath:  “/sites/ SharepointSite /Lists/ custom/ custom.aspx”
  30. siteAbsoluteUrl: http://svr:2525/sites/ SharepointSite &#8220;
  31. siteClientTag: “0$$15.0.4433.150615.0.4433.1506
  32. siteServerRelativeUrl; “/sites/ SharepointSite “
  33. systemUserKey: “i:0).w|s-1-5-21-2086049…90378103-3194450012-500”
  34. tenantAppVersion: “0”
  35. userId: 1
  36. webAbsoluteUrl: http:// svr:2525/sites /sites/SharepointSite&#8221;
  37. webLanguage: 1033
  38. webLogoUrl:“_layouts/15/images/siteicon.png”
  39. webPermMasks: Object { High=2147483647, Low=4294967295}
  40. webServerRelativeUrl: “/sites/ SharepointSite “
  41. webTemplate: “1”
  42. webTitle : ” SharepointSite “