Thursday, November 24, 2016

Force update analytics components timer job

Issue: The popular items report for the document library are updated every 24 hrs and we cannot get the recent hits updated immediately.

Workaround: Following is the workaround to get the recent hits updated in the most popular items report for a document library

Prerequisite: Make sure that Reporting feature and Popularity Trends/usage analytics is enabled for the site

1. Make sure that the Search Analytics timer job is started.
$analyticsJob = Get-SPTimerJob -Type Microsoft.Office.Server.Search.Analytics.AnalyticsJobDefinition
$searchanalytics = $analyticsJob.GetAnalysis("Microsoft.Office.Server.Search.Analytics.SearchAnalyticsJob")

  1. Trigger the events by opening and downloading some files from document library

  1. Make sure that the usage files @ C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\LOGS\RequestUsage are updated with the event details.

  1. Events can be imported from usage to Event store by running the Timer Job manually using following PowerShell script

$usagejob = Get-SPTimerJob -Identity ("job-usage-log-file-import")

  1. Make sure that the event store (C:\Program Files\Microsoft Office Servers\15.0\Data\Office Server\Analytics_<GUID>\EventStore)  is updated with the event

  1. Copy the current data event store logs to a custom folder location. In this example we have copied the logs to following location
    15 Hive\Data\Office Server\Analytics_<GUID>\EventStore\20161124\MyEvents

  1. Run the following PowerShell script to start the usage analytics

$uajob = get-sptimerjob -type
$uajob.StartAnalysis("\\ilinksys-121\Office Server\Analytics_abce7b74-9002-404b-92b2-126bcddf451e\EventStore\20161124\MyEvents")

Check the most popular items report once the job state is complete and you notice that the recent events are updated.

Thursday, November 17, 2016

Retrieve Popular items Programmatically In SharePoint using SOM


In this article, we’ll see how to retrieve popular items based on view counts programmatically using SOM.


Make sure that you have enabled the reporting feature under site collection features in the site to see the popular documents.

The following lines of code retrieve the data and update the results in a Data table.

using System;
using System.Linq;
using Microsoft.SharePoint;
using Microsoft.Office.Server.Search.Query;
using System.Data;

namespace GetPopularItems
   class Program
       static void Main(string[] args)
           DataTable table = new DataTable();
table.Columns.Add("ItemID", typeof(Int32));
           table.Columns.Add("Name", typeof(String));
           table.Columns.Add("Recent", typeof(Int32));
           table.Columns.Add("Views", typeof(Int32));

           string siteurl = "http://SiteURL/";
           string docLibURL = "http://SiteURL/Shared%20Documents";

           using (SPSite siteCollection = new SPSite(siteurl))
               using (SPWeb rootWeb = siteCollection.OpenWeb())

                   KeywordQuery keywordQuery = new KeywordQuery(siteCollection);
var properties = keywordQuery.SelectProperties; properties.Add("ListItemID");
                   keywordQuery.QueryText = "Path:"+ docLibURL;
                   SearchExecutor searchExecutor = new SearchExecutor();
                   ResultTableCollection resultTableCollection = searchExecutor.ExecuteQuery(keywordQuery);
                   var resultTables = resultTableCollection.Filter("TableType", KnownTableTypes.RelevantResults);
                   ResultTable resultTable = resultTables.FirstOrDefault();
                   DataRowCollection dataTable = resultTable.Table.Rows;
                   for (var i = 1; i < dataTable.Count; i++)
                       DataRow datarowObj = table.NewRow();
datarowObj["ItemID"] = resultTable.Table.Rows[i][(resultTable.Table.Columns["ListItemID"]).Ordinal];
                       datarowObj["Name"] =  resultTable.Table.Rows[i][(resultTable.Table.Columns["Path"]).Ordinal];
                       datarowObj["Recent"] = resultTable.Table.Rows[i][(resultTable.Table.Columns["ViewsRecent"]).Ordinal];
                       datarowObj["Views"] = resultTable.Table.Rows[i][(resultTable.Table.Columns["ViewsLifeTime"]).Ordinal];

Monday, November 14, 2016

The administration service is running so all administration jobs will be run in the timer service.

Environment: SharePoint 2013

Scenario: Tried to run the following powershell cmdlet to execute all administrative timer jobs immediately rather than waiting for the timer job to run.


 Issue: Command failed and got following error message

 Error: Start-SPAdminJob : The administration service is running so all administration jobs will be run in the timer service.


Go to Services.msc and stop the SharePoint Administration service and try again. Start the service once the command is completed executing.

 Alternatively use net stop SPAdminV4 and net start SPAdminV4 cmdlet to stop and start the SharePoint Administration service

Friday, November 11, 2016

we don't have data for this item right now. Please try again later.

Environment: SharePoint 2013 Enterprise On-Premise
Scenario: Trying to check the Popularity Trends report and most popular item in the document libraries.
Issue: we got the below error message when tried to export the popularity report or most popular item report by clicking the Usage under Usage Reports section.
Error: we don't have data for this item right now. Please try again later.
Resolution: Check if the SharePoint Timer job is running and Search Service Application is started. Create and configure Search Service application if not started already.
Refer to the following blog post for configuring Popularity trends.

Friday, October 21, 2016

The required version of SharePoint Foundation or SharePoint Server is not installed on this system. The target version of the SharePoint project is 16.1.

Scenario: To create and deploy a provided hosted app for SharePoint online.

Issue: Error occurred in Visual Studio 2015 on deploying solution

Error: The required version of SharePoint Foundation or SharePoint Server is not installed on this system. The target version of the SharePoint project is 16.1.

Resolution: Since this solution is targeted to SharePoint online, make sure that the host SharePoint site is provided with SharePoint online URL. This issue might occur when the site URL is pointed to SharePoint 2013 on-premise environment.

SharePoint Provided Hosted App
SharePoint Provided hosted App

Tuesday, October 4, 2016

Architectural Style

Architecture styles and patterns as sets of principles that shape an application. This following table describes and discusses architecture styles and principles commonly used for applications today. For each style, you will find an overview, with example and information that will help you choose the appropriate architectural styles for your application


Architecture styles



Segregates the system into two applications, where the client makes requests to the server. In many cases, the server is a database with application logic represented as stored procedures.
When a bank customer accesses online banking services with a web browser (the client), the client initiates a request to the bank's web server. The customer's login credentials may be stored in a database, and the web server accesses the database server as a client. An application server interprets the returned data by applying the bank's business logic, and provides the output to the web server. Finally, the web server returns the result to the client web browser for display.
In each step of this sequence of client–server message exchanges, a computer processes a request and returns data. This is the request-response messaging pattern. When all the requests are met, the sequence is complete and the web browser presents the data to the customer.

Consider the client/server architectural style if:

  • Your application is server-based and will support many clients.
  • You are creating Web-based applications exposed through a Web browser.
  • You are implementing business processes that will be used by people throughout the organization.
  • You are creating services for other applications to consume.
  • You want to centralize data storage, backup, and management functions.
  • Your application must support different client types and different devices.
N-Tier / 3-Tier
Segregates functionality into separate segments in much the same way as the layered style, but with each segment being a tier located on a physically separate computer.
In the web development field, three-tier is often used to refer to websites, commonly electronic commerce websites, which are built using three tiers:
A front-end web server serving static content, and potentially some cached dynamic content. In web based application, Front End is the content rendered by the browser. The content may be static or generated dynamically.
A middle dynamic content processing and generation level application server (e.g., ASP.NET, Ruby on Rails, Django (web framework), Laravel, Spring Framework, CodeIgniter, Symfony, Flask (web framework))
A back-end database or data store, comprising both data sets and the database management system software that manages and provides access to the data.

Consider the 3-tier architectural style if:
  • You are developing an intranet application where all servers are located within the private network.
  • You are developing an Internet application, and security requirements do not restrict implementing business logic within the public-facing Web or application server.

Consider using more than three tiers if:
  • Security requirements dictate that business logic cannot be deployed to the perimeter network.
  • The application makes heavy use of resources and you want to offload that functionality to another server
Component-Based Architecture
Decomposes application design into reusable functional or logical components that expose well-defined communication interfaces.
  • An individual software component is a software package, a web service, a web resource, or a module that encapsulates a set of related functions (or data).
  • You already have suitable components, or can obtain suitable components from third-party suppliers.
  • Pluggable architecture
e.g., financial applications or business software, Salesforce’s Lightning Design System.

Consider the component-based architectural style if:
  • You already have suitable components, or can obtain suitable components from third-party suppliers.
  • Your application will predominantly execute procedural-style functions, perhaps with little or no data input.
  • You want to be able to combine components written in different code languages.
  • You want to create a pluggable architecture that allows you to easily replace and update individual components.
A design paradigm based on division of responsibilities for an application or system into individual reusable and self-sufficient objects, each containing the data and the behaviour relevant to the object.
E.g. system of the automatic teller machine, an order processing application
Consider the object-oriented architectural style if:
  • You want to model the application based on real-world objects and actions.
  • You already have suitable objects and classes that match the design and operational requirements.
  • You need to encapsulate logic and data together in reusable components.
  • You have complex business logic that requires abstraction and dynamic behaviour.
Layered Architecture
Partitions the concerns of the application into stacked groups (layers).
E.g. 1. Line of business (LOB) applications, such as accounting and customer-management systems.
2. Enterprise Web-based applications and Web sites.
3. Application for restaurant
The main actors are: the customer, the waiter and the Chef
They all have different responsibilities. It is good idea to build your site / application using Layered architecture if following principles are met
  • Have clear separation of responsibilities — each layer being only responsible for itself
  • Exposed workflow — as opposed to the spaghetti code we’ve all see way too many times
  • Ability to replace one or several layers implementation with minimum effort and side effects.
  • Your application is complex, and the high-level design demands separation so that teams can focus on different areas of functionality.
  • You want to implement complex and/or configurable business rules and processes.
  • Your application must support different client types and different devices.
Message Bus
An architecture style that prescribes use of a software system that can receive and send messages using one or more communication channels, so that applications can interact without needing to know specific details about each other.
D-Bus is an open source unix-based tool for inter process communication (IPC) that utilizes the message bus architecture.  D-Bus was designed to address communication between applications in the same desktop session, and between a desktop session and the operating system. D-Bus uses both the  call-and-return and event-based varieties of message passing [19] between applications to  facilitate these concerns
Consider the message-bus architectural style if:
  • You have existing applications that interoperate with each other to perform tasks.
  • You are implementing a task that requires interaction with external applications.
  • You are implementing a task that requires interaction with applications hosted in different environments.
  • You have existing applications that perform specific tasks, and you want to combine those tasks into a single operation.
Service-Oriented Architecture (SOA)
Refers to applications that expose and consume functionality as a service using contracts and messages.
  • Amazon's code base API (Amazon Web Service) which respond to web requests.
  • Reservation system (Starwood Hotels and Resorts)
  • Sharing of medical data (Harvard Medical School)

Consider the SOA style if:
  • You have access to suitable services, or can purchase suitable services exposed by a hosting company.
  • You want to build applications that compose a variety of services into a single UI.
  • You are creating Software plus Services (S+S), Software as a Service (SaaS), or cloud-based applications.
  • You need to support message-based communication between segments of the application.
  • You need to expose functionality in a platform-independent way.
  • You want to take advantage of federated services, such as authentication.
  • You want to expose services that are discoverable through directories and can be used by clients that have no prior knowledge of the interfaces.
  • You want to support interoperability and integration.
Domain Driven Design
An object-oriented architectural style focused on modelling a business domain and defining business objects based on entities within the business domain.
E.g. Project Silk, Home loan processing system

Consider the DDD style if:

  • You are developing software of extremely high essential complexity (with a lot of correlated business rules).
  • And/or software with clear future, where the Domain Model can outlast the infrastructure
  • where the business requirements change fast