Thursday, 9 December 2010

Error message when adding a new column:

Culture ID 1164 (0x048C) is not a supported culture.
Parameter name: culture

The file "Microsoft.SharePoint.ApplicationPages.dll" has not been updated in the app_bin folders for each virtual server.

1. Stop the IIS service.
2. Copy the file from 12Hive\Config\Bin to all app_bin which have SP installed
3. The version of the file "Microsoft.SharePoint.ApplicationPages.dll" should be "12.0.6548.5000"
4. Start the IIS service again.

Friday, 3 December 2010

Downgrade of Enterprise to Standard editon for Sharepoint 2010

Downgraded a SQL cluster from Enterprise to Standard edition. Removed the cluster nodes first, followed parts of this guide to downgrade the edition and then configured the cluster again (most time was needed for the cluster configuration).

If you don´t restore the master database, you need to run "GRANT VIEW SERVER STATE TO [MyDomain\FarmAccount]" to avoid flooding of "Event 5586" with error message "
The user does not have permission to perform this action."

One thing that is not to obvioulsy is that the "Property Store" and "Web Analytics Service Reporting" database uses Enterprise functionality and can not be attached to a Standard edition.
You need to recreate the Service Applications for the Search Service and Web Analytics. So plan for it beforehand.

The Search Service can not be deleted i the UI, check this how to use stsadm to delete it. You also need to delete the Search DBs in the same way or else the Event viewer will be filled with connection errors for the orphan databases.

Wednesday, 10 November 2010

Code example for EnabledScript element in Ribbon XML

Andrew Connel explains how to enable and disable buttons in the Ribbon based on a condition.

I need to check a field value on the selected item and the item permission and then enable / disable multiple buttons. I assume that you have some knowledge about the Ribbon XML structure :).


//Should only be enabled when IssueStatus == Report
      <CommandUIHandler
Command="Tab.CloseIssue"
CommandAction="javascript:EditDeviation('{ListId}');"
EnabledScript="javascript:SingleEnable('Report',SP.PermissionKind.editListItems);"/>

//Should always be enabled
      <CommandUIHandler
Command="Tab.CurrentStatus"
CommandAction="javascript:DisplayStatus('{ListId}');"
EnabledScript="javascript:SingleEnable('All',,SP.PermissionKind.viewListItems);"/>


function SingleEnable(EnableForStatus, PermissionKind) {

var result = false;

var selectedItems = SP.ListOperation.Selection.getSelectedItems();
var ci2 = CountDictionary(selectedItems);
if (ci2 == 1) {

if (this.IssueRibbonItemId == null) {

this.IssueRibbonItemId = selectedItems[0]['id'];
var listGuid = SP.ListOperation.Selection.getSelectedList();
getStatus(this.IssueRibbonItemId, listGuid);

}
else if (this.IssueRibbonItemId != selectedItems[0]['id']) {

this.IssueRibbonItemId = selectedItems[0]['id'];
var listGuid = SP.ListOperation.Selection.getSelectedList();
getStatus(this.IssueRibbonItemId, listGuid);
}
else if(this.IssueRibbonStatus != null){

if (this.IssueRibbonStatus == EnableForStatus || EnableForStatus == '') {
if(this.IssueItem.get_effectiveBasePermissions().has(PermissionKind)){
result = true;
}
}
}
}

return result;
}

function getStatus(ItemId, listGuid) {

var clientContext = new SP.ClientContext();
var web = clientContext.get_web();
var lists = web.get_lists();
var list = lists.getById(listGuid);
this.IssueItem = list.getItemById(ItemId);

clientContext.load(IssueItem, 'IssueStatus', 'EffectiveBasePermissions');
clientContext.executeQueryAsync(Function.createDelegate(this, this.onStatusQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));
}


function onStatusQuerySucceeded(sender, args) {
this.IssueRibbonStatus = this.IssueItem.get_item("IssueStatus");
RefreshCommandUI(); //Makes the EnabledScrip method to be enabled again.
}

function onQueryFailed(sender, args) {
alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
}

Monday, 1 November 2010

Some TaxonomyField things and code

Before a new term can be used for tagging in a web site it needs to be added to the hidden list "TaxonomyHiddenList".
Several suggestions how to add a new term with code has been posted and this is my conclusion:

Adding a new term to an item:

TaxonomyField tf = item.Fields["ColumnName"] as TaxonomyField;
tf.SetFieldValue(item,term);
item.Update();

This doesn´t work for new items:

int hiddenTermId = -1;
int[] wssIds = TaxonomyField.GetWssIdsOfTerm(site, TermStore.Id, TermSet.Id, Term.Id, false, 1);

if(wssIds.Length > 0)
hiddenTermId = wssIds[0];

TaxonomyFieldValue tfv = new TaxonomyFieldValue(termId + ";#" + term.Name + TaxonomyField.TaxonomyGuidLabelDelimiter + term.Id.ToString())

or this:

string termString = String.Concat("-1", SPFieldMultiColumnValue.Delimiter, term.GetDefaultLabel(1033));
TaxonomyFieldValue tfv = new TaxonomyFieldValue(termString);

Add a comment if you have any question.

Friday, 27 August 2010

MissingSetupFile for themes

Running Test-SPContentDatabase for migration preparation. The report contained errors referring to missing themes files. The web didn´t use the theme as the active theme but had used the theme before.

Start SPD and open the site. Browse to the themes folder and delete the theme folder referenced in "MissingSetupFiles". Open the web in the browser and delete the folder from the Recycle Bin and then also from the site collection Recycle Bin.

Tuesday, 6 July 2010

Unexpected error creating debug information file

In several of my SharePoint projects I'm using a WinForm application to test and trigger SP code.

Sometimes I have had big problems when recompiling the SP projects and generating the PDB file. This time I disabled the VSHOST option for my WinForm project and the problem was solved.

VS spawns a new winformexe.vshost.exe process each time I tried to kill it with Process Explorer, so it kept me from recompiling the other SP corrctly.

How to: Disable the Hosting Process

Monday, 10 May 2010

WSPBuilder and VB.Net

Developing a solution for a client which want´s the sourcecode in VB.Net (It took some hours before I stopped using ";" and "{}" ;) ).

A known fix for getting all ASP.Net items available in a WSPBuilder project is to amend the .csproj file with a ProjectTypeGuids element. The same goes for VB.Net but the element that needs to be added is different:

{349c5851-65df-11da-9384-00065b846f21};{F184B08F-C81C-45F6-A57F-5ABD9991F28F}

Wednesday, 28 April 2010

WebTemplate

Have noticed a long awaited feature in SP2010: WebTemplate! This means that you can add a template definition for one site collection only and not for the whole farm.

Monday, 26 April 2010

MCPD!

Passed the last certification and got the rewarded the MCPD credential. Actually the first title since my MCSE for Windows Server 2000. Have only been taking subject specific certificats since then, mostly SharePoint ofcourse.

Wednesday, 21 April 2010

jQuery and the find selector

When working with XML in jQuery a selector called $find can be used to find elements in the XML object that is loaded. I had a problem with IE7 and a webservice returning XML. The problem was that IE 7 didn´t recognize the returning XML as an [object] but rather as a string. Adding a dataType attribute to AJAX method solved the problem.

Solution reference: http://www.gammageek.com/2008/10/jquery-xml-in-ie.html

Wednesday, 24 February 2010

Enable debugging for _layouts files

I wanted to see the ASP.net error for files in a subdirectory to _layouts folder. So I created a web.config in the subfolder with this content:


<configuration>
<sharepoint>
<safemode maxcontrols="200" callstack="true" directfiledependencies="10" totalfiledependencies="50" allowpageleveltrace="false">
<pageparserpaths>
</pageparserpaths>
</safemode>
</sharepoint>
<system.web>
<compilation batch="false" batchtimeout="600" maxbatchsize="10000" maxbatchgeneratedfilesize="10000">
<httphandlers>
<add type="System.Web.UI.PageHandlerFactory, System.Web, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" path="*.aspx" verb="*">
</httphandlers>
<customerrors mode="Off">
</SYSTEM.WEB>
</configuration>

Save the file and your ASP.Net error messages will appear.