Monday, February 15, 2016

SharePoint tips - How to identify which is Web Front End and which is App Server?

Ever wonder how to identify the type of serve in your SharePoint Farm?

Easy.

Go to Central Administration à Application Management à Manage Services On Server.

You’ll get a list of services in a grid with an option selection picker to select your server on the top right hand side of the grid.

­­­­


Search for the service which titled “Microsoft SharePoint Foundation Web Application”
This service is Started only on Web Front End Servers.

So here’s the logic.

If Microsoft SharePoint Foundation Web Application service is started on a server à That server acts as a Web Front End Server

If Microsoft SharePoint Foundation Web Application service is stopped on a server à That’s your Application Server.



Sunday, February 14, 2016

SharePoint tips - Deleting multiple SharePoint lists and libraries at once

Ever came across a situation where you want to delete multiple lists / libraries in your SharePoint site?

Well, it’s pretty easy.

Login to your SharePoint Site.
Go to Site Settings (/_layouts/settings.aspx) à Click on Content and Structure under the Site Administration category.



You’ll see a nice tree structure of your site.

Simply select the lists/libraries you want to delete from the right pane and then in the ribbon click Actions à Delete.


That’s it. You’ve deleted the lists you wanted from your site.  Piece of cake. :D

Wednesday, February 27, 2013

Culture ID 2155 (0x086B) is not a supported culture for Windows 2003 , VS 2008 and MOSS 2007 environment

Couple of days back I was working on a Windows 2003 environment which had MOSS 2007 and Visual Studio 2008.
I was getting frequent memory dumps and some windows files got corrupted. Then the machine was recovered by repairing the OS.
However after that's done I was not able to build any SharePoint project with visual studio.

It kept on giving me this error.

"Invalid argument. Culture ID 2155 (0x086B) is not a supported culture"

I searched the net and wasted a whole Saturday on this and wasn't able to find a proper answer.
Most of the guys were saying that the issue is with the .net framework.

I repaired the .net framework
Reinstall the .net framework
Use .net framework cleanup tools
Uninstall VS
Uninstall MOSS2007

But nothing gave me the solution.

Then finally I found out that the issue was with the Windows Server 2003 Service Packs.

This issue is observed only in Windows Server 2003 SP1.

By installing the SP2 for Windows Server 2003 (32 bit is here, 64 bit is here ) I was able to fix the issue.





Thursday, July 7, 2011

How to delete a field from a list view in SharePoint 2010

In my previous post Add a field to a list view in SharePoint 2010 I talked about how to add a field to a list view. Today we’ll look how to remove a field from a list view.

Just like adding, you can do this by selecting the modify view button and deselecting the field that you want to delete from the current view.

Here’s how it’s done via code.

public static void RemoveFieldFromListView(string webUrl, string fieldStaticName, string listName)
{
using (SPSite site = new SPSite(webUrl))
{
using (SPWeb web = site.OpenWeb())
{                  
SPList list = null;
bool contains = false;
//This block will validate whether the given list is exists at the given web.
try
{
list = web.Lists[listName];
contains = true;
}
catch (Exception ex)
{
//Do your custom exceptions handling here.
}
if (contains)
{
try
{
web.AllowUnsafeUpdates = true;
SPField field = web.Lists[listName].Fields.TryGetFieldByStaticName(fieldStaticName) as SPField;// get the field using the static name of the field.
SPView view = list.DefaultView;/ get the default view.
if (view.ViewFields.Exists(field.StaticName)) // field is already in the view.
{
view.ViewFields.Delete(field); // delete the field from the view.
view.Update();// update the view
list.Update();// update the list
web.Update();// update the web
}
}
catch (Exception ex)
{
//Do your custom exceptions handling here.
}
finally
{
web.AllowUnsafeUpdates = false;
}
}                   
}
}
}

How to add a field to a list view in SharePoint 2010

Today I’m going to share my experience on modifying list views programmatically.
When you are developing, you might come across scenarios such as modifying the list views to add fields to the list view.

You can do this quite easily by selecting the modify view button and selecting the field that you want to add to the current view.


( That is straight forward. Why do you need to write a blog on this?)
Hold on….
How about this ? What if you need to do this via code?
Now I got your attention.

I also had to face such a situation in one of my projects, where my client wants to incorporate enhancements not as fresh deployments, but as upgrades.
So I spent some time and come up with a handy method which will add an existing field to a given list view.
I’m going to share it with you all, so you guys don’t need to reinvent the wheel.

Here’s the code.

public static void AddFieldToListView(string webUrl, string fieldStaticName, string listName, int? position)
{
using (SPSite site = new SPSite(webUrl))
{
using (SPWeb web = site.OpenWeb())
{
SPList list = null;
bool contains = false;
//This block will validate whether the given list is exists at the given web.
try
{
list = web.Lists[listName];
contains = true;
}
catch (Exception ex)
{
//Do your custom exceptions handling here.
}
if (contains)
{
try
{
web.AllowUnsafeUpdates = true;
//some times you need extra privileges to execute code.
SPSecurity.RunWithElevatedPrivileges(delegate()
{
SPField field = web.Lists[listName].Fields.TryGetFieldByStaticName(fieldStaticName) as SPField; // get the field using the static name of the field.
SPView view = list.DefaultView; // get the default view.
if (view.ViewFields.Exists(field.StaticName)) // field is already in the view.
{
return;
}
view.ViewFields.Add(field); // add the field to the default view.
if (position.HasValue && position.Value < view.ViewFields.Count) // if the position is given, set the position of the field in the view.
{
view.ViewFields.MoveFieldTo(field.StaticName, position.Value);
}
view.Update();// update the view
list.Update();// update the list
});
web.Update();// update the web
}
catch (Exception ex)
{
//Do your custom exceptions handling here.
}
finally
{
web.AllowUnsafeUpdates = false;
}
}
}
}
}

Wednesday, February 2, 2011

How to apply changes to fields in an existing page layout content type which is in use.

Seems to be very straight forward to do, but I came across lot of trouble doing this and thought it is worth to share it with you all.

 

I had a multi lookup field name topics in my page layout content type which retrieve data from a share point list.

Initially my lookup field allow only 255 characters. So the problem was when  the number of topics are large, if I try to add more topics it will give an error saying

 

This field can have no more than 255 characters.

 

So as a workaround for that I add the lookup field attribute UnlimitedLengthInDocumentLibrary=”true” and redeploy it.

But the error was still there.

Then I delete all the pages that were referring to my page layout and then delete the page layout and deactivate the content type.

Then I reactivate the content type and restore the page layout and pages. But the error was still there.

 

Workaround

Here is the solution that I come up with. Even though you deactivate and activate the content type , somehow it reference to the old field definition.

In order to overcome this

1.      go to the site content types-> select the relevant content type

2.       select the field on which you did  the modification

3.       click on edit site column

4.       then do nothing. Yes do nothing and click ok.

5.       You are done!

 

Tuesday, February 1, 2011

How to Remove a sealed column in SharePoint 2010 using powershell or sharepoint manager.

Last week when I was working with a sharepoint list, I needed to add a page content field for testing purposes. After  sometime I wanted to remove it.
Strangely I couldn’t do that. Typically when you want to remove a field to a list in sharepoint web frontend, you can easily do that by
1.       go to the list settings
2.       click on particular field in the list
3.       then click on the remove button in the left hand side. (near OK,Cancel) button.

But this time I couldn’t do that.  After spending some time and thanks for my mate Diluk, I figured it out what should be done.
When you add a page content field it will created as sealed column and by default sharepoint doesn’t allow to delete sealed columns.

For that we can use either Sharepoint powershell commands or Sharepoint Manager.

Using Powershell Commands
The following steps provide the way to remove it using powershell commands.
1.       Run SharePoint 2010 Management Shell as administrator. SharePoint 2010 Management Shell can be found under the Microsoft SharePoint 2010 Products in start menu.
2.       Connect to the site
$site
$web = $site.RootWeb
$web
$list = $web.Lists["topics"]
$list
$field = $list.Fields["Page Content"]
$field
After this you need to  set the field properties “Allowdeletion” to true and “Sealed” to false

$field.Allowdeletion = $true
$field.Sealed = $false

Then you can delete the field

$field.Delete()

Make sure to update the list after deletion

$list.Update()

Now you are done!

Using Sharepoint Manager Tool

1.       Run the Sharepoint Manager Tool in your machine (you can download it here)
2.       Go to Content Service -> Web Applications -> Your Site -> Site Collection -> Your Site Collection Url -> Fields
3.       Expand the Field list and select the relevant field
4.       On the right hand side pane you can see the field properties.
5.       Find AllowDeletion property and set it to true.
6.       Find Sealed property and set it to false.
7.       Then right click on the field on the left pane and click Delete.
8.       That’s it!