Showing posts with label Sharepoint 2013. Show all posts
Showing posts with label Sharepoint 2013. Show all posts

Thursday, December 19, 2013

SharePoint 2013 TypeLoadException Error when set up BDC

If you set up the BDC model and you may get an error in ULS log as below,


The Type name for the Secure Store provider is not valid. ---> System.TypeLoadException: Could not load type 'Secure Store Service' from assembly 'Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'. 
InnerException 1: System.TypeLoadException: Could not load type 'Secure Store Service' from assembly 'Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'.   


The reason is that in the BDC service application, its external system instance not set up correctly for the property "secure store implementation", when the instance is created it is blank, not like SharePoint 2010 the value is pre-populated, so naturally by the name definition, I put in the secure store service proxy name such as "Secure Store Provider".

This is wrong, what we should put is the type name as below,
Microsoft.Office.SecureStoreService.Server.SecureStoreProvider, Microsoft.Office.SecureStoreService, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c

Then it worked.

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()

Wednesday, May 22, 2013

Everyday common SharePoint development issue and timps

Now I am back to start some SharePoint 2013 development work. Then there are some issues and useful links that I need every day. I write them down here in case later I need it again.

1. Deployment solution from visual studio and have this error,
"recycle iis application pool' :object reference not set to an instance of an object".
Just close visual studio and start again, then it worked.

2. Search in ShaePoint 2013 is a great function and their search API in REST is very useful,
http://blogs.msdn.com/b/nadeemis/archive/2012/08/24/sharepoint-2013-search-rest-api.aspx

The search address is in http://server/_api/search/query/?querytext='...'&selectproperties=''&startrow=..&rowlimit=..

3. Remove a web part from a page,
Sometimes the web part is not functionall as expected and needs to be disconnected from the page then enter the http://server/page_address?contents=1

4. Force reinstall fetaure in visual studio
Sometimes I am getting this error in deployment,
"Error occurred in deployment step 'Add Solution': A feature with ID xxxx-xxx-xxx-xxx has already been installed in this farm"
Need to set the AlwaysForceInstall = "True".
By the way, ImageUrl can be added to show a different feature image.

5. How to find the list template ID
Go to Site Contents -> Create list -> then right click on the page to get the url, the template ID is there.
Also a similar way can be used to get the associated content type ID.



Wednesday, May 15, 2013

Add a sign in as different user in SharePoint 2013

By default, the "Sign-in as different user" option is removed in the site. And this is a very useful function for development and testing purpose.

In the folder,
C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\TEMPLATE\CONTROLTEMPLATES

Edit the Welcome.ascx page to add the following link,
         <SharePoint:MenuItemTemplate runat="server" ID="ID_LoginAsDifferentUser"
                 Text="<%$Resources:wss,personalactions_loginasdifferentuser%>"
                 Description="<%$Resources:wss,personalactions_loginasdifferentuserdescription%>"
                 MenuGroupId="100"
                 Sequence="100"
                 UseShortId="true"
                 />
Done :)

Monday, January 21, 2013

SharePoint 2013 Search - Build Query for the specified List only

Just tried with the SharePoint search and their refinement.

1. A custom movie list with the necessary columns has been created.
    The new column will be created as crawl property as ows_columnname
    To used them in the search refinement, the managed property needs to be created and mapped back to the crawl property, also make sure the refinable attribute is set true.

2. A custom search page is created in the pages library.

3. Go to the Site Search Settings (not site collection search settings) to add the new created page in search navigation

4. Go to the created page and edit the web part. On the left, the refiner can be modified as required.

5. The query in search result webpart needs to be updated to query the list only.
Here is the issue I have to get the query correct. It seems to be natural to use the Path contains the ListName. However, that would not work. Path has to include the complete list path.


 
 



The below is what the final search page look like.
 

Saturday, January 19, 2013

SharePoint View BCD List get the error "Login failed for user "NT AUTHORITY\ANONYMOUS LOGON"

The reason is the BDC is created from SharePoint designer and the authentication mode is set to "Connect with user's identity"

If enable the BDC with RevertToSelf to true, then the authentication mode can be set to "BDC identity"

Run the following PS command to set the BDC RevertToSelfAllowed to true.

$bdc = Get-SPServiceApplication | where { $_ -match "Business Data Connectivity Service" }
$bdc.RevertToSelfAllowed =$true
$bdc.Update()



Install SharePoint 2013 workflow Issue - Unable to load one or more of the requested types, Retrieve the LoaderExceptions property for more information.

To be able to use SharePoint workflow 2013, I have configured workflow manager 1.0 successfully.
as http://www.aboutworkflows.com/2012/07/sharepoint-2013-install-sharepoint-2013.html

Then run this command in SharePoint PowerShell,
Register-SPWorkflowService -SPSite http://SERVERNAME -WorkflowHostUri http://SERVERNAME:12291 -AllowOAuthHttp

I got the following error,
Unable to load one or more of the requested types.
 Retrieve the LoaderExceptions property for more information.
At line:1 char:1
+ Register-SPWorkflowService –SPSite "http://mysharepointserver" –WorkflowHostUri "h
ttp:/ ...


The reason is because of the SharePoint Developer Tools for visual studio 2012 preview is also installed.

- Uninstall the sharepoint developer tools for visual studio 2012 preview
- Restart Server
- Run the powershell command again then it worked.
- Also a new office developer tools for visual studio 2012 preview 2 has been released, so I just installed that from web platform installer.

Sunday, December 9, 2012

Sharepoint show detailed error message

To show a detailed error message, the site web.config needs to be modified with the following things,
1. CustomErrors = Off
2. CallStack = true
3. Debug=true

However, it is still possible to hit the following screen,

 
There is another web.config in _layouts folder need to be modified as well,
 
 

Saturday, December 8, 2012

SharePoint 2013 - Create a search app

It is not hard to create an App for search to use search javascript.

The search REST service is at http://site/_api/search/query?querytext='querytext'

In the app, need to add search permission,
 
In the default app page, the following html elements are defined.
<div id="toolbarDiv">
 
<input type="text" id="queryTerms" />
<button onclick="executeQuery($get('queryTerms').value); return false;">Search</button>
</div>
 
 
And here is the example script to send the query text to search service and display the results.

function executeQuery(queryTerms) {
    Results = {
        element: '',
        url: '',
        init: function (element) {
            Results.element = element;
            Results.url = _spPageContextInfo.webAbsoluteUrl + "/_api/search/query?querytext='" + queryTerms + "'";
        },
        load: function () {
            $.ajax({
                url: Results.url,
                method: "GET",
                headers: { "ACCEPT": "application/json" },
                success: Results.onSuccess,
                error: Results.onError
            });
        },
        onError: function (error) { alert(JSON.stringify(error)); },
        onSuccess: function (data) {
            var results = data.d.query.PrimaryQueryResult.RelevantResults.Table.Rows.results;
            var html = "<table>";
            for (var i = 0; i < results.length; i++) {
                html += "<tr><td>";
                html += results[i].Cells.results[3].Value;
                html += "</td><td>";
                html += results[i].Cells.results[6].Value;
                html += "</td></tr>";
                }
            html += "</table>";
            Results.element.html(html);
        }
    }
    Results.init($('#resultsDiv'));
    Results.load();
       
}

SharePoint Search - how to reate a custom template view

In SharePoint 2013, rather than using XST, it can be created in html and javascript.

1. Create the template

In the Search Site, go to Site Settings -> Master Pages and Page Layout
In the Display Templates / Search Folder,
Based on the existing template and create custom template.html and upload to here.
In the page properties, make sure content type is Item Display Template and the target control type is for Search Results.

2. Set up the template to be used

In the search site, go to Site Settings -> Result Types,
Create a new Result Type and select it to use the new template






Wednesday, November 28, 2012

SharePoint 2013 layout folder path

Just realized that SharePoint 2013 now has two folders for _layout virtual directory.
 _layout --> layout/14
_layout/15 --> layout/15

Saturday, November 24, 2012

SharePoint customization content types reference links

During customization in SharePoint solution development, it is always be nice to have a reference in hand to know all the field types and re

SharePoint 2010 field types reference
http://koenvosters.wordpress.com/2010/04/27/available-field-types-in-sharepoint-2010/

Tuesday, November 20, 2012

SharePoint 2013 Apps is an opportunity

Now SharePoint 2013 is out. Since the beta version with the new Apps programming model, I have talked to many developers. Like what I first see this, most of them are disappointed. Apps is not something the SharePoint developers really want, it moves to another direction rather than giving us something better and easier for SharePoint server solutions development.

My opionion about this actually has been changed. I think SharePoint team is on the right track and we need to embrace this model. Since SharePoint 2007, all the versions were built on top of asp.net. And in these years, web development has been changed so much because of the the power of javascript library. In MVC4, you have all the good javascript library included in the box to do amazing things that give very good user experience.

Since SharePoint 2013 has a good revamp in their client javascript library, developers finally can do things like the modern web apps can do. So now SharePoint developers have the tools in hand and can work with them in SharePoint 2013. I believe it is time to leave your comfortable zone and start to write your own mordern web apps within SharePoint.

Monday, November 19, 2012

SharePoint 2013 - View data through REST from browser

Now many information can be loaded from browser through REST. This is a quick links list to show what you can expose,

First, In IE, needs to go to Internet Options -> Content tab -> feeds and web slices -> settings
uncheck "turn on feed reading view"

http://spsite/_api/web - list all SharePoint related information
http://spsite/_api/web/lists - all the SharePoint site lists
http://spsite/_api/web/lists/getbytitle('listname') - specific list information
http://spsite/_api/web/lists/getbytitle('listname')/items - show the list data
http://spsite/_api/web/lists/getbytitle('listname')/items(int) - show the list data by id
http://spsite/_api/web/lists/getbytitle('listname')/items(int)?$select=Title,Field1,Field2 - only select the list fields
http://spsite/_api/web/lists/getbytitle('listname')/items?$filter=Title eq 'title'  fitler the data

The reference can be found out in http://www.odata.org -> document -> URL Convention

Here has a very good tutorial about how to do write operation in REST, and how to consume it in JSON data.