Monday, June 10, 2013

Correctly add the javascript intellisense for SharePoint 2013 for Visual studio 2012

In visual studio 2012, it is quite easy to add a javascript intellisense.

Add a scripts folder and in the folder add an _reference.js file to reference the javascripts.
Such as,
/// <reference path="/LAYOUTS/My_custom_package/jquery-1.10.1.js" />
For adding the SharePoint 2013 client javascript library, the below codes are needed.
/// <reference name="MicrosoftAjax.js" />
/// <reference path="~/_layouts/15/init.js" />
/// <reference path="~/_layouts/15/SP.js" />
/// <reference path="~/_layouts/15/SP.Runtime.js" />
/// <reference path="~/_layouts/15/SP.UI.Dialog.js" />
/// <reference path="~/_layouts/15/SP.Core.js" />
 

 

Saturday, June 8, 2013

Sharepoint 2013 Search Experience

It is generally good experience in SharePoint search. However there are a few issues needs to wait maybe until the service pack out.

1. The search result web part is not able to return custom managed property, it seems to be an existing bug that any extra managed property can not return the data even it is shown on REST.
http://social.msdn.microsoft.com/Forums/en-US/sharepointsearch/thread/f53c87d0-af81-445c-8338-1bfea6ca780e

2. Event the document id feature is activated, the docId managed property is only returning integer even after a full crawl. A second managed property has to be created to point to the previous crawl property as ows__l_docId, then it works.

3. For the content search web part, there are limitation to allow five managed properties in the design template, and the paging has no page numbers.

4. When the search crawling is stuck in "Full Crawling" status, reboot worked.

And some references regarding to search,
http://social.technet.microsoft.com/Forums/en-US/sharepointsearch/thread/3878d445-9772-4852-aea2-4f35d072b60e


SharePoint Load ClientContext

This how to load ClientContext

var clientContext;
var website;

SP.SOD.executeFunc('sp.js', 'SP.ClientContext', sharePointReady);

// Create an instance of the current context.
function sharePointReady() {
    clientContext = SP.ClientContext.get_current();
    website = clientContext.get_web();

    clientContext.load(website);

    clientContext.executeQueryAsync(onRequestSucceeded, onRequestFailed);
}

function onRequestSucceeded() {
    alert(website.get_url());
alert(g_wsaSiteTemplateId );
}
function onRequestFailed(sender, args) {
    alert('Error: ' + args.get_message());
}

SharePoint Search master page

Recently worked on the custom master page, and the master page should be applied in the search site collection as well, then here is the tricky things.

In the search site collection page, the default.aspx page has style sheet that disable the ribbon div.
And in the results.aspx page, the titlerow is also made invisible, and the logo is moved below.

g_wsaSiteTemplateId variable is available to know the base template of the site.

So to make it be consistent with the original master page, javascirpt code can used to manually make those div blocks enabled.

_spBodyOnLoadFunctionNames.push("start");
function start(){...}

or include jquery such as,
if (g_wsaSiteTemplateId.substring(0, 4) == "SRCH")
{
//set the div back to visible
                $('#s4-ribbonrow').css({'display':'block', 'height':'30px'});
                $('#s4-titlerow').attr('style', 'display: block !important;');              
                $('#searchIcon').css({'display':'none' , 'height':'0px'});
}