Wednesday, July 10, 2013

SharePoint 2013 and IE 10 work together

I access the SharePoint 2013 sites using IE 10, then if I tried to go to Site Settings page, I got this error,

An error has occurred with the data fetch. Please refresh the page and retry.

F12 to open the developer tools I can see it is a SCRIPT5: Access is denied error.

There are a few options to look at,

1. Check IE10 browser compatibility
Hold ALT-T, and go to Compatibility view settings to set up the SharePoint site.

2. Disable Tracking Protection

3. Add the site to the trusted sites from internet options

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'});
}







Thursday, May 23, 2013

Get the Site Content Type ID and feature ID in powershell

Sometimes the site content type ID is needed for development.
Go to Site Settings -> Site Content Type -> Content Type,
The content type ID is in the URL.

In Powershell, the following scripts are useful for the content types enumeration,
$sitecollection = Get-SPSite http://localhost
$sitecollection.RootWeb.ContentTypes include all the site content types

To get the specific content type by its ID
$c = $sitecollection.RootWeb.ContentTypes | where {$_.Id -eq "0x....."}

Also if create the custom content type page in visual studio, the elements.xml need to specify the PublishingAssociatedContentType such as,
<Property Name="PublishingAssociatedContentType" Value=";#Custom Article;#0x010100C568DB52D9D0A14D9.....;#" />

To list all the features
$site.Features to list all the site collection features.
$site.Features["GUID"] to get the specific feature

Also Get-SPFeature
Get-SPFeature -site http://site | where {$_.DisplayName -eq "..." }

There is a very useful tip to list the object properties
ps_object | Get-Member







 

Add user as term store administrators from powershell

To be able to import the data into the term store, the user has to have the permission to do it, which is set in the "Managed metadata web service" service application.

Also it can be easily done in power shell as such,

$taxonomySession = Get-SPTaxonomySession -Site "http://localhost"
$termStore = $taxonomySession.TermStores["Managed Metadata Web Service Proxy"]

$termStore.AddTermStoreAdministrator("administrator")
$termStore.CommitAll()