SharePoint miscellaneous examples

This SharePoint tutorial we will discuss various SharePoint miscellaneous examples.

  • Full trust and Code Access Security (CAS) in SharePoint
  • Fetch data from list and create an item from list accross site in SharePoint 2010 web service
  • Advantages of SharePoint specific webpart class
  • Export Import option in SharePoint 2010
  • SharePoint 2013 Noderunner.exe processes eating up your CPU and memory
  • This tab has been recovered, a problem with this page caused internet explorer to close and reopen this tab error in SharePoint 2010
  • Failed to provision the SharePoint Central Administration Web Application error
  • What to be consider before branding in SharePoint?
  • Customize Change quick launch style and design SharePoint
  • Get attachment URL from list by parsing XML in SharePoint 2010
  • Get user information using client object model in SharePoint 2013
  • SharePoint: Space changed to underscore while downloading file in internet explorer 7
  • Why SharePoint Hosting?
  • Lookup columns in SharePoint 2010
  • Get XML data from CoreResultsWebPart SharePoint

Full trust and Code Access Security (CAS) in SharePoint

Now, we will discuss how full trust and Code Access Security (CAS) works in SharePoint 2010 and we will check the limitations and benefits.

Code Access Security

  • This is partial trust model.
  • The assemblies will be deployed to the bin directory of the corresponding SharePoint web application.
  • The solution will be scoped to the web application only, not to the farm level.
  • Any other files like resource or image files will be deployed to the SharePoint root directory.

Full Trust

  • In case of Full trust the assemblies in your solution are deployed to the global assembly cache on each Web front-end server and application server in the server farm.
  • Here the code will run with full trust and runs without any code access security restrictions.
  • Here the solution will be available to any web application on the server farm.

Fetch data from list and create an item from list accross site in SharePoint 2010 web service

This tutorial explains, how to fetch data from a SharePoint List and how to create an item in a list across a site.

Lists.asmx Service

The Lists Web service provides methods for working with SharePoint lists, content types, list items, and files.

To access this Web service set a Web reference to http:///_vti_bin/Lists.asmx .

Some of the Methods of this Services are as follows -:

  • UpdateListItems: Adds, deletes, or updates the specified items in a list on the current site.
  • GetListCollection: Returns the names and GUIDs for all lists in the site.
  • GetListItems: Returns information about items in the list based on the specified query.

Advantages of SharePoint specific webpart class

Now, we will discuss what are the advantages of SharePoint specific web part class in SharePoint 2010.

In SharePoint 2010 we can inherit the web part from the SharePoint specific base class name as Microsoft.SharePoint.WebPartPages.WebPart as well as normal Asp.Net base class namely System.Web.UI.WebControls.WebParts.WebPart.

If it uses SharePoint specific class then it is also fully integrated with the ASP.NET Web Parts infrastructure, because the SharePoint’s WebPart class internally inherits from that of ASP.NET.

But these web parts can be used only in SharePoint since it depends on Microsoft.SharePoint.dll.

It is not a best practice to inherit from Microsoft.SharePoint.WebPartPages.WebPart, But still they have some advantages over normal asp.net web part base class.

Advantages:

  • It supports the SharePoint tool parts.
  • You can use these to inject tokens in the output HTML code of a SharePoint Web Part, and then have the SharePoint infrastructure replace them with their corresponding values.
  • It supports cross-page connections and connections between Web Parts that are outside of a Web Part zone.
  • It supports client-side connections.
  • It also supports data caching, it allows caching of web parts into the content database.

Export Import option in SharePoint 2010

This example explains, how to take backup of the Site collection in SharePoint 2010.

Though SharePoint 2010 provides an option for export where SharePoint 2010 allows you to export websites and lists and also an import option, where a user can import a site or a list.

Export:

You can use central administration, stsadm or PowerShell to export a site or a list.

Stsadm:

STSADM -o export -url <url> -filename <filename>

There are also lots of optional parameters are available.

PowerShell:

Export-SPWeb <url> -path <filename>

There are also lots of optional parameters are available.

Still, it has some limitations for which we should use backup rather than export.

Limitations of Export:

  • Export is just like copy a web site.
  • But here are some characteristics that export will not keep like Settings not preserved are workflow associations and instances, file check-out status, alert subscriptions, tags and notes, and personal Web part settings.
  • It takes a long time and places a large burden on your farm.
  • Microsoft is recommending not to export more than 1 GB.

Import:

You can use stsadm or PowerShell to import a website or a list. But to import a site first the top-level site should be created with the matching site definition (like team site or blank site etc) and also no content needs to be there.

SharePoint will create the child websites automatically, but top-level site needs to be created before import.

If you are importing a list, if the lists exist then it must be the same template. If the list does not exist SharePoint will create.

Stsadm command:

STSADM -o import -url <url> -filename <filename>

There are also lots of optional parameters are available.

PowerShell commad:

Import-SPWeb <url> -Path <filename>

There are also lots of optional parameters are available.

SharePoint 2013 Noderunner.exe processes eating up your CPU and memory

Unless you have very powerful hardware or virtual machines, anyone who has tried installing a full install of the new version of SharePoint 2013 probably has run into problems with a bunch of noderunner.exe processes in your task manager just eating up practically all of your RAM and CPU making it very hard for you to do any development.

Follow the steps below to limit the CPU and RAM impact on your system:

In PowerShell, use the following to reduce the CPU impact the search service has on your test environment.

Set-SPEnterpriseSearchService -PerformanceLevel Reduced

Modify the C:\Program Files\Microsoft Office Servers\15.0\Search\Runtime\1.0\noderunner.exe.config so that it can only consume an X amount of RAM by changing the following value to any amount of RAM you like to contain the memory leak.

<nodeRunnerSettings memoryLimitMegabytes="0" />

This tab has been recovered, a problem with this page caused internet explorer to close and reopen this tab error in SharePoint 2010

Now, we will discuss how to fix the error “This tab has been recovered, a problem with this page caused internet explorer to close and reopen this tab”.

Full Error Message:

This tab has been recovered, a problem with this page caused internet explorer to close and reopen this tab.

Background:

Some of the users have reported that while using the SharePoint sites with IE8 they are getting above error message. Based on the above grounds we started with the basic troubleshooting such as.

Troubleshooting:

  • Checked the Excel file to open from SharePoint site, causing the error.
  • Checked to open another file from SharePoint site, causing the error.
  • Downloaded the file from the SharePoint to local machine and tried to open them, no issues found.
  • This seems to be an issue with IE as all the files are being blocked not only Excel files.

Resolution:

Use Internet Explorer (IE) by temporarily disable all add-ons. You can do this by following the steps below.

  • Click the Start button and select click All Programs,
  • Click Accessories and then click on System Tools,
  • Click Internet Explorer (No Add-ons).
  • If the above method didn’t work then, optimize IE using the below steps.
  • Clear cached data in Internet Explorer
  • Open Internet Explorer 8.
  • Click Safety, and then click Delete Browsing History.
  • In Delete Browsing History area, click Delete.
  • Reset security settings for Internet Explorer
  • Open Internet Explorer.
  • Click Tools, and then click Internet Options.
  • Click the Security tab.
  • Click Reset all zones to default level, and then click OK.
  • Tried to open the sites and they are opening fine.

Reference:
Reference-1
Reference-2

Failed to provision the SharePoint Central Administration Web Application error

Now, we will discuss how to fix error “Failed to provision the SharePoint Central Administration Web Application”.

Error:

Failed to provision the SharePoint Central Administration Web Application.
An exception of type System.Runtime.InteropServices.COMException was thrown. Additional exception information: Filename: \?\C:\inetpub\wwwroot\wss\VirtualDirectories\46824\web.config
Line number: 25

Error: There is a duplicate ‘system.web.extensions/scripting/scriptResourceHandler’ section defined

Solution 1:

You need to configure IIS features options. IIS Options can be configured from Control Panel -> Programs and Features -> Turns Windows Feature On Off

Solution 2:

If you are getting this issue in sharepoint reinstallation, then open IIS manager ->delete Central Administration V4 site and Central Administration V4 app pool and Re-run the SharePoint administration, configuration wizard. It will work fine.

Solution 3:

  • Clear the cache, open drive:\ProgramData\Microsoft\SharePoint\Config\Guid, delete all XML file and open cache.ini, then set the number to 1
  • Open IIS and go to SharePoint Web Services, right-click add permissions
  • Add the domain user (I used domain admin) and grant full control. Return the SharePoint 2013 wizard finish the wizard.

What to be consider before branding in SharePoint?

Now, we will discuss what needs to be considered before branding in SharePoint 2010. For any website, branding is very important because “A word is a word, and a picture is worth a thousand…but a brand is worth a million”

So before doing branding in SharePoint find out the answer of following questions and then start customization.

  • One of the first decisions to make is which version of SharePoint will be used for the project?
  • Is there an existing website or SharePoint site that the new SharePoint site will replace?
  • What screen resolution will be targeted for your SharePoint branding
  • What browsers and operating systems will be supported by your SharePoint site
  • Will master pages or SharePoint themes be used to create the branding? Will both be required?
  • Will this be a new design or will it be based on some existing branding?
  • Is there an existing corporate style guide that needs to be followed?
  • Are there any stylistic requirements, such as preferred or disliked colors, fonts, or image?
  • Who will the audience be?
  • What sort of navigation is required? Horizontal navigation? Vertical navigation? Both?
  • Will any third-party Web Parts or controls be needed?
  • How will the branding be deployed to the production SharePoint server?
  • What is the timeframe to deliver the new branding?

After getting an answer to these question start SharePoint designer and start branding.

Customize Change quick launch style and design SharePoint

Now, we will discuss how to change quick launch style and design in SharePoint. To modify quick launch style and make it as menu look and feel like this:

Step 1: Open master page v4master.master page in SharePoint designer

Step 2: Download images from the following links and upload them in the SharePoint site assets library.

http://photouploads.com/images/bckhover.jpg
http://photouploads.com/images/menubg.png

Step 3: Refer the links in css

Copy the below style and place in .css file and upload to style library.

DIV #s4-topheader2 {
PADDING-BOTTOM: 2px; BACKGROUND: url(http://md-jayabharathi:28586/SiteAssets/BCKHover.jpg) repeat-x; BORDER-TOP: 0px
}
.s4-toplinks {
TEXT-TRANSFORM: uppercase; BACKGROUND: url(http://md-jayabharathi:28586/SiteAssets/BCKHover.jpg); FONT-SIZE: 14px; FONT-WEIGHT: bold
}
.s4-tn .menu LI A.static {
BORDER-BOTTOM: medium none; BORDER-LEFT: medium none; PADDING-BOTTOM: 10px; PADDING-LEFT: 10px; PADDING-RIGHT: 10px; FONT-FAMILY: "Helvetica Neue" , Arial, Helvetica, sans-serif; COLOR: #fff; BORDER-TOP: medium none; BORDER-RIGHT: medium none; PADDING-TOP: 10px
}
.s4-tn .menu LI A.selected {
BACKGROUND-IMAGE: none; BORDER-BOTTOM: medium none; BORDER-LEFT: medium none; BACKGROUND-COLOR:#5500FF; MARGIN: 0px; BORDER-TOP: medium none; BORDER-RIGHT: medium none
}
.s4-tn .menu LI A.static:hover {
BACKGROUND: #fff; COLOR: #5500FF; TEXT-DECORATION: none
}
DIV #s4-searcharea {
POSITION: relative; TOP: 10px
}
.s4-ql UL.root UL {
MARGIN-BOTTOM: 0px
}
.s4-ql UL.root > LI > .menu-item {
PADDING-BOTTOM: 1px; MIN-HEIGHT: 30px; BACKGROUND: url(http://md-jayabharathi:28586/SiteAssets/BCKHover.jpg) no-repeat 0px -10px; FONT-SIZE: 1em; PADDING-TOP: 1px
}
.s4-ql UL.root UL > LI > A {
PADDING-BOTTOM: 1px; MIN-HEIGHT: 30px; BACKGROUND: url(http://md-jayabharathi:28586/SiteAssets/BCKHover.jpg) no-repeat 0px -10px; PADDING-TOP: 1px
}
.s4-ql UL.root > LI > .menu-item:hover {
BACKGROUND: url(http://md-jayabharathi:28586/SiteAssets/menu_bg.png) no-repeat 0px -10px; TEXT-DECORATION: none
}
.s4-ql UL.root UL > LI > A:hover {
BACKGROUND: url(http://md-jayabharathi:28586/SiteAssets/menu_bg.png) no-repeat 0px -10px; TEXT-DECORATION: none
}
.menu-vertical .menu-item-text {
TEXT-TRANSFORM: uppercase; COLOR: white; FONT-SIZE: 1em; FONT-WEIGHT: bold; PADDING-TOP: 5px
}

/*.s4-ba{
width:821px;
height:665px

}*/
.mytable
{
border-collapse:separate;
border-spacing: 1px;
width:100%;
}
.ribbonbackground, .s4-title {
background:url(‘/SiteAssets/bannernew.png’) no-repeat 0 0 !important;
}

Step 4:
Refer to the above .CSS in master page as given below

<SharePoint:CssRegistration name="<% $SPUrl:~sitecollection/Style Library/CUSTOMCSS.css %>" runat="server" After="corev4.css"/>

Hope this code help you to change quick launch menu style.

Get attachment URL from list by parsing XML in SharePoint 2010

This SharePoint tutorial explains, how we can get an attachment URL from a list by parsing XML in SharePoint 2010. The below code can be used to get the attachment URL of any list item by just passing the item ID.

function getAttachmentURL(id , callback)
{
var requestUri = _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/getbytitle('Announcements')/items('"+id+"')/AttachmentFiles" ;
$.ajax({
type: "GET",
url: requestUri,
dataType: "xml",
async:false,
success: function(xml){
xmlDoc = (new XMLSerializer()).serializeToString(xml);
xmlDoc = xmlDoc.replace(/d:ServerRelativeUrl/g, 'ServerRelativeUrl');
//alert(xmlDoc);
callback($(xmlDoc).find("ServerRelativeUrl").text(),title,body,data);
},
error: function() {
alert("An error occurred while processing XML file.");
}
});
}

This is how we can get attachment URL from list by parsing XML in SharePoint 2010.

Get user information using client object model in SharePoint 2013

This SharePoint 2013 client object model tutorial explains, how we can get a user information using the client object model code in SharePoint 2013.

Below is the full code to get user information using client object model in SharePoint 2013.

var userNameList=new Array();
function getAllUserNames() {
//generate query

var query = url + "_vti_bin/listdata.svc/UserInformationList()/?$select=Name,Id&$filter=ContentType eq 'Person'";
jQuery.ajax({
url: query,
async:false,
success: function (data) {
//loop though the data
//alert(data);
$(data).find("content").each(function () {
var userID = 0;
var strName = "None";

//get the data
userID = $(this)[0].childNodes[1].childNodes[3].textContent;
strName = $(this)[0].childNodes[1].childNodes[1].textContent;

//add to dictionary as well
addItemToDictionary(userID, strName);
});
}
});
}

function addItemToDictionary(key, value, arrayName) {
if (typeof arrayName != 'undefined’ && arrayName != null) {
arrayName.push(new keyvaluePair(key, value));
}
else {
userNameList.push(new keyvaluePair(key, value));
}
}

function keyvaluePair(id, value) {
if (typeof id != 'unidentified’ && id != null) {
this.id = id;
this.value = value;
}
}

This is how we can retrieve user information using client object model in SharePoint 2013.

SharePoint: Space changed to underscore while downloading file in internet explorer 7

This SharePoint 2010 tutorial explains how to resolve one IE 7 issue while downloading files in SharePoint 2010.

Issue:

Whenever a user is trying to download a file from SharePoint site its Spaces gets replaced with the special character underscore (-).

Background:

A user had a long file name with spaces and when he downloads the file. The spaces get replaced with underscore _. For example filename “Amardeep SharePoint Public.ppt” will be replaced with “Amardeep_SharePoint_Public.ppt”.

Troubleshooting:

  • I tried every possible solution to check on this issue such as uploading multiple files with different extensions.
  • Tried files with short names and long names.
  • I tried repairing the office package.
  • It was showing issue on most of the machines, however on the machine where we had IE 8 and above this working as expected.
  • It was more of an issue with the machine where we have IE 7 and was not upgraded yet.
  • If this is the case then there should be a justification, some publication available from Microsoft.
  • Showing some more curiosity had led me to the resolution of the issue.

Resolution:

  • There was hotfix released by Microsoft and it’s a known issue with IE7 only.
  • Link to obtain Hotfix is: http://support.microsoft.com/kb/952730
  • You can also have your IE upgraded to next version to have this issue resolved.

Applies to: IE 7, SharePoint 2007 and SharePoint Server 2010.

Why SharePoint Hosting?

SharePoint is a platform for sites and collaboration which is already known and appreciated by customers from all over the world and different areas of business. With this platform, they have got a flexible, reliable and compliant tool for with a great range of functionalities with a help of which business process became more effective.

Usually, there are two ways to get SharePoint Services – subscribe it within tenant environment or dedicated. The dedicated environment gives the company farm administrator permissions, full access to the Central Administration, Remote Desktop Protocol (RDP), SQL databases and so on.

Usually, the smallest dedicated solutions can serve 100-200 users and have 100 GB of space storage. Within dedicated SharePoint customers have no limitation on their services; they can do whatever they want there and upgrade the server at any time. This sounds great. But the costs for the dedicated environment are much higher than in “shared”.

And what about companies with limited IT capability and which requires data storage in much smaller amounts. Fortunately for such organizations, there are companies that host SharePoint. They offer SharePoint in a shared environment. It is the hosting company performs root control of the servers and uses the “Multi-tenancy” feature to allocate private SharePoint sites to hosting customers.

Additionally, they maintain data security between customer sites in the shared environment. Hosting plans are based on a required space storage and richness of the functionality. Customers may choose the plan which meets their own business needs and save their costs.

However, if server root control, large data storage (minimum 100 GB), 100% white label branding, or using custom web part applications are required for the company shared environment will not work and it`s better to choose dedicated plans.

It is up to the company to decide which services would it need and which functionalities. But in any case, I would recommend choosing a reliable hosting company, which is critical to a successful SharePoint hosting experience, provides a high level of performance and security, and what is a more high level of support.

Lookup columns in SharePoint 2010

Lookup columns in SharePoint 2010 are used to establish a relationship between list items in one list and related items in another list. Though in Lookup columns are introduced in MOSS 2007, There are significant changes in SharePoint 2010 for lookup columns.

Some of the changes are:

  • Now in SharePoint 2010, you can show display other columns from the target list with the lookup columns, which are also known as projected columns.
  • Now in SharePoint 2010 lookup columns now support referential integrity, which prevents users from deleting an item in the target list if it is referenced in one or more items in the related list.
  • Now you can configure cascade delete behavior which says if an item is deleted in the target list, all the referenced items in the related list are deleted as well.
  • There is a limit which specifies the maximum number of lookup columns a query at one time which is also known as List View Lookup Threshold, can be set from Central Administration site -> Manage Web Applications -> General Settings -> Resource Throttling.

Get XML data from CoreResultsWebPart SharePoint

Now, we will discuss how to get XML data from CoreResultsWebPart SharePoint. We often want to debug the XSLT code that we have written for our CoreResultsWebPart, this post will help you to extract the data from the CoreResultsWebPart and later which we can apply to debug our custom XSLT written for the CoreResultsWebPart.

Prerequisites:

You need to have the Administrator privileges.
Basic understanding of creating web applications and running the FAST search.

TODO:

The first thing you need to do is get the Basic Fast Search Center site up and running. Below I have mentioned the brief steps.

Create Web application with classic mode authentication. Create a root site collection with “Fast Search Center” template.

Open the root site collection and try to search, as long as it displays the result you are fine.

First Step: Edit the page and replace the default XSL with our custom XSL
As your Site is up and running, search for any term and go to the results page. Edit the page from Site Actions -> Edit Page
Search for the Search Core Results web part on the page and edit the web part. In the search core results editor pane, go to the Core Results->Display properties.

Uncheck the “Use Location Visualization” option, by default it would be checked.

Note: It means that site has to use the columns and XSL defined at the federated location level. Which is shared by all the search sites in the farm? When we uncheck this option we can define our own XSL format. More information on this topic can be found here.

On unchecking this option the area under Fetched Properties and XSL editor will be enabled.

Fetched Properties are the columns that you want to be retrieved from the FAST search database. The columns mentioned within these properties will only be fetched.

You may like following SharePoint tutorials:

This SharePoint tutorial, we learned below things:

  • Full trust and Code Access Security (CAS) in SharePoint
  • Fetch data from list and create an item from list accross site in SharePoint 2010 web service
  • Advantages of SharePoint specific webpart class
  • Export Import option in SharePoint 2010
  • SharePoint 2013 Noderunner.exe processes eating up your CPU and memory
  • This tab has been recovered, a problem with this page caused internet explorer to close and reopen this tab error in SharePoint 2010
  • Failed to provision the SharePoint Central Administration Web Application error
  • What to be consider before branding in SharePoint?
  • Customize Change quick launch style and design SharePoint
  • Get attachment URL from list by parsing XML in SharePoint 2010
  • Get user information using client object model in SharePoint 2013
  • SharePoint: Space changed to underscore while downloading file in internet explorer 7
  • Why SharePoint Hosting?
  • Lookup columns in SharePoint 2010
  • Get XML data from CoreResultsWebPart SharePoint
free sharepoint training

SharePoint Online FREE Training

JOIN a FREE SharePoint Video Course (3 Part Video Series)

envelope
envelope

Bijay Kumar

I am Bijay from Odisha, India. Currently working in my own venture TSInfo Technologies in Bangalore, India. I am Microsoft Office Servers and Services (SharePoint) MVP (5 times). I works in SharePoint 2016/2013/2010, SharePoint Online Office 365 etc. Check out My MVP Profile.. I also run popular SharePoint web site SharePointSky.com

>