Monday, September 24, 2012

Windows 8 App-a-thon at Microsoft Belgium on September 28th

There will be 2 coding sessions, 1 for Day Birds from 10am – 4pm and one for Night Owls from 6pm – 12am. You can join us for one or both sessions. Build an app, have fun and go home with a fantastic prize!

Don’t forget to register.

Thursday, September 20, 2012

The web template feature in SharePoint 2010

In SharePoint 2007 you had two options when you needed to create a new template for a SharePoint site:

In SharePoint 2010, there is a new replacement and improved framework for handling site templates. When you save a site as template it will create a normal SharePoint Solution Package (a wsp file – if this is new for you take a look at WSP – SharePoint Solution Files). The new webtemplate feature allows you to build a “site definition” which is scoped to a site collection – this way you can built templates of a site and still deploy them to the SharePoint solution gallery in sandbox mode.

Every webtemplate is based on an existing site definition – listed below is a code sample using the minimal set of attributes that you have to use when creating a new webtemplate.

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<WebTemplate
BaseTemplateID="1"
BaseTemplateName="STS"
BaseConfigurationID="1"
Name="JOPX"
Title="JOPX WebTemplate"
>
</WebTemplate>
</Elements>


The WebTemplate has to reference the Template (BaseTemplateName) and the configuration of the site definition (BaseConfigurationId) the template is based on.



The example on MSDN How to: Create a webtemplate starts from importing an existing saved webtemplate but in some cases it is easier to start from an empty SharePoint project and manually adding a elements.xml incorporating the webtemplate feature as well as the ONET.XML from the site definition from which you want to start.



References:



Sunday, September 16, 2012

Exploring an App for SharePoint 2013 Visual Studio 2012 project – SharePoint hosted apps

After having installed Visual Studio 2012 together with the Microsoft Office Dev Tools which are distributed with the Web Platform Installer 4.0 (Just search for Office within Web PI) you can start building your first SharePoint 2013 apps. There is only one project type for building SharePoint 2013 apps.

After having selected the SharePoint 2013 app template, you will need to decide what type of app you want to build.

Let’s start with exploring what is included in the Visual Studio 2012 project after you have selected SharePoint hosted app.

Visual Studio 2012 SharePoint 2013 App structure:

  • Features folder – which contains a .feature configuration file, which is used to deploy features to the server that's running SharePoint. This file is typically edited using the VS Feature Designer
  • Package folder - which contains a Package.package file, which is used to deploy the solution to the server that's running SharePoint.
  • Content folder
            • App.css : CSS file to style your SharePoint 2013 app. For guidelines about the different styles take a look at Apps for SharePoint UX design guidelines
            • Elements.xml: provisions the CSS file into the App web
  • Images folder
          • AppIcon.png : serves the icon for the app in the home page
          • Elements.xml: provisions the icon into the App web
  • Pages folder
          • default.aspx : Main/starter page of the app which is shown in full screen mode. Every app needs a least one page likes this. Appmanifest.xml points to this app starter page
          • Elements.xml: provisions the default.aspx file into the App web
  • Scripts folder
          • App.js – Script file for adding your own Javascript logic
          • JQuery-1.6.2.js – If you are not familiar with JQuery yet – you should definitely pick up some learning material on this topic – it is quite essential for building SharePoint 2013 apps. In essence JQuery is a Javascript library which allows you to easily select and manipulate items in the DOM. See JQuery.com for more information
          • JQuery-1.6.2.min.js – Minified version of the JQuery library
          • JQuery-1.6.2.vsdoc.js – Used to provide intellisense capabilities – see How do I get intellisense for JQuery? for more info
  • Root of the project
          • Appmanifest.xml - defines the various elements of the SharePoint 2013 app itself. The appmanifest.xml tells SharePoint what it must know about the app and defines the app's most important properties such as ProductID, Version, Title, Tile and StartPage Urls
            , different AppEvent Urls: Installed, Uninstalling, Upgraded and the App Permission requests.
          • For more information, see Explore the app manifest and the package of an app for SharePoint
          • Packages.config - When creating a SharePoint 2013 app  project in Visual Studio 2012, NuGet packages are used for the JQuery libraries. This means that instead of using whatever version is installed on your machine (via the SDK), Visual Studio will pull the latest version from NuGet. You can see this by looking into the packages.config file in your project.

If you take a look at default.aspx you will notice the following javascript snippet added in to the page – this is quite important – and provides the binding with the business logic which is added into app.js

   1: <script type="text/javascript">



   2:     $(document).ready(function () {



   3:         SP.SOD.executeFunc('sp.js', 'SP.ClientContext', function () { sharePointReady(); });



   4:     });



   5: </script>




The snippet above uses the jQuery document ready event handler – “ $(document).ready(function())” to call SP.SOD.ExecuteFunc(). This is an example of a common pattern in Javascript called anonymous function calls. SP.SOD.ExecuteFunc(key,functionname,fn) ensures that the specified file - sp.js - that contains the specified function – SP.ClientContext - is loaded and then runs the specified callback.



So when both the DOM and SP.js are loaded and the ClientContext object is initialized the code will call the sharePointReady() function which is located in App.js.



If you look at the code in App.js – you will notice that the general way of working with the  Javascript Client Object Model hasn’t changed a lot in SharePoint 2013.





   1: // The code creates a context object which is needed to use the SharePoint object model



   2: function sharePointReady() {



   3:     context = new SP.ClientContext.get_current();



   4:     web = context.get_web();



   5:  



   6:     getUserName();



   7: }




References:







Saturday, September 15, 2012

About intent, recall, relevance and precision of search solutions

One of the challenges of designing a good search solution is understanding the range of different search requirements from users. When you look at the Google search screen (or a SharePoint search center screen for that matter) it is quite minimalistic. The trick is to look for the intention of the user who is performing a search operation.

So what is the user looking for?

Key in delivering a good search result is the fact whether the search engine has understood the unstated question. Traditional metrics which are commonly used to measure the efficiency and effectiveness of search are the following:

  • Relevance = whether a document is relevant depends on your intent in the search. Basically, relevant results will help you achieve the goals that made you perform the search in the first place
  • Recall = the amount of total relevant documents which are retrieved by your search. A good recall means that not many documents are missing. If you know that there are 1000 relevant documents and the search would retrieve 100, the recall would be 10%. This metric is quite hard to measure in real life and is you should use this during a search validation phase where you are using a controlled, experimental environments.
  • Precision: the percentage of relevant documents in relation to the number of documents retrieved. If your search retrieves 100 documents and 20 of these are relevant, your precision is 20%. The opposite measure is called fallout, if you retrieve 100 documents and 20 are relevant, your fallout is 80%. Fallout becomes a bigger problem as the size of your search corpus become larger and your retrieved result set also gets larger. Scanning 80 irrelevant documents to fin 20 relevant ones may not be so bad, but with a 1000 results returned – this can be quite painful. Precision and recall typically go in opposite directions, when the query is broad, the recall is high, but precision is low and vice versa ….

The measure with which it all start is relevance – and relevancy is dependent on the intent of the user. In any organization there will be a range of different search requirements from users, depending on the purpose for which they are searching. If you are serious about building a good search experience you should identify common tasks that user are trying to achieve when performing a search. These requirements are best identified though the development of search personas and scenarios. For more information on identifying personas and search information design take a look at the links listed below:

Tuesday, September 11, 2012

Visual Studio 2012 Virtual Launch Event September 12th

Don’t forget to mark September 12th 9:30 AM Pacific Time (for Belgium – 18:30 PM) in your agenda and follow the Visual Studio 2012 Virtual Launch event on http://www.visualstudiolaunch.com

Tuesday, September 04, 2012

Exploring the REST API options in SharePoint 2013– Part I

In SharePoint 2010 the Client Side Object Model (CSOM) was made available through the _vti_bin/client.svc. Client.svc wasn’t really build to be accessed directly but calls would go through supported entry points (proxies)  being the 3 flavours of the CSOM:

  • Silverlight Client Side Object Model
  • Javascript Client Side Object Model
  • .Net Client Side Object Model

Unfortunately the Javascript CSOM was harder to use then the managed version and also more limited in functionality. SharePoint 2010 also provided oneREST/oData enabled service called  ListData.svc also referred to as WCF Data Services (See Introduction to oData and SharePoint Server 2010 for more info)

In SharePoint 2013 the client.svc service is extended with REST capabilities and it now support direct access from REST clients which makes it easier for javascript and non .NET code to access it.  There is also a new shorthand notation for accessing the REST API where CSOM URLs can go through the _api folder.

This means that you can now replace

http://sharepoint/_vti_bin/client.svc/web

with

http://sharepoint/_api/web

The new SharePoint 2013 REST API follows the oData protocol specification but also extends it in some ways to support more complex SharePoint specific operations. The SharePoint 2013 Preview REST service responses are formatted by using the Atom protocol by default. But it is also possible to use HTTP Accept headers that enable you to specify that the response is returned in JSON format which is easier to use in Javascript code.

Since a number of REST calls are simple GET operations it is possible to learn the syntax by creating the URL in a browser and looking at the ATOM response being returned. Next are a number of examples to get you started:

  • https://[yoursharepointsite]/_api/web/ – access a specific site and retrieves different properties
  • https://[yoursharepointsite]/_api/web/?$select=Title,Id – only retrieves the Title and ID for a specific site
  • https://[yoursharepointsite]/_api/lists  - retrieves all lists on a specific site
  • https://[yoursharepointsite]/_api/lists/getByTitle(‘Consultants’) – retrieves a single list based on the title used
  • https://[yoursharepointsite]/_api/lists/getByTitle(‘Consultants’)/Items – retrieves all items in the list with all the fields returned
  • https://[yoursharepointsite]/_api/lists/getByTitle(‘Consultants’)/Items/?$select=Title,LastName – retrieves for all items in the list only the Title and LastName field
  • https://[yoursharepointsite]/_api/web/lists/getByTitle('Consultants')/Items/?$select=Title,FirstName&$filter=startswith(Title,'C') – retrieves  items in the list where the Title starts with a C and retrieves the Title and LastName field

In a next post I’ll explore the extensions in the REST API for SharePoint Server 2013.

More information:

Monday, September 03, 2012

SharePoint 2013 App Developer videos

There is lot of hours of video material available  around building apps for SharePoint – check out SharePoint 2013 Developer training videos for all modules.  To get you started you should  with SharePoint 2013 app development, you should definitely take a look at the following modules (in total around 7 hours of training material around SharePoint 2013 app development alone)

  • Module 1 – Introduction to Office 2013 and SharePoint 2013 development
          • New features for Office 2013 and SharePoint 2013 (00:06:59)
          • App scenarios for Office 2013 and SharePoint (00:06:20)
          • Development options for Office 2013 and SharePoint 2013 (00:10:20)
  • Module 5 – SharePoint 2013 app model for developers
          • Why apps for SharePoint 2013? (00:04:16)
          • Introducing the app model for SharePoint 2013: Part I (00:19:46)
          • Introducing the app model for SharePoint 2013: Part II (00:20:07)
  • Module 6 – SharePoint 2013 developer tools
          • Development model for apps for SharePoint 2013 (00:21:45)
          • Design Patterns for apps for SharePoint 2013 (00:12:59)
          • Create SharePoint 2013 app projects (00:19:37)
          • Package and deploy apps for SharePoint 2013 (00:11:55)
  • Module 7 – Create hosted apps in SharePoint 2013
          • SharePoint hosted-apps model for SharePoint 2010 (00:21:34)
          • SharePoint hosted app model for SharePoint 2013 (demo - 00:15:28)
          • Using Javascript and Jquery for SharePoint 2013  (00:26:25)
          • Using Javascript and Jquery for SharePoint 2013 (demo - 00:20:36)
          • SharePoint 2013 chrome control (00:11:47)
    • Module 8 – Create cloud-hosted apps for SharePoint 2013
        • SharePoint 2013 App Hosting models (00:16:07)
        • Developer hosted apps for SharePoint 2013 (00:21:31)
        • Windows Azure auto-provisioned apps for SharePoint 2013 (00:13:19)
    • Module 9 – SharePoint 2013 client object model (CSOM) and REST API
          • SharePoint 2013 strategy for SharePoint client object model (CSOM) and REST (00:09:13)
          • Programming SharePoint client object model (CSOM) with C# and Javascript for SharePoint 2013 (00:16:03)
          • SharePoint 2013 REST and oData fundamentals (00:17:58)
          • Making REST calls with C# and Javascript for SharePoint 2013 (00:17:30)
          • Making REST calls with C# and Javascript for SharePoint 2013 (demo - 00:17:43)
    • Module 10 – oAuth and application identity in SharePoint 2013
        • SharePoint 2013 application identiy and permissions (00:15:56)
        • Requesting and granting application permissions in SharePoint 2013 (00:16:54)
        • SharePoint 2013 oAuth implementation (00:21:01)
        • Authentication using server-to-server high trust in SharePoint 2013 (00:18:46)

Happy SharePoint-ing