web 2.0

Error while setting Farm level Search setting under Search Service in the Central Administration

Got an error while trying to configure the Farm Level Search Setting :(

Object reference not set to an instance of an object.   at Microsoft.SharePoint.Portal.Search.Admin.Pages.SearchAdminPageBase.ErrorHandler(Object sender, EventArgs e)
   at Microsoft.SharePoint.Portal.Search.Admin.Pages.SearchCentralAdminPageBase.OnError(EventArgs e)
   at System.Web.UI.Page.HandleError(Exception e)
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
   at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
   at System.Web.UI.Page.ProcessRequest()
   at System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context)
   at System.Web.UI.Page.ProcessRequest(HttpContext context)
   at ASP._admin_searchfarmsettings_aspx.ProcessRequest(HttpContext context)
   at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
 

 

Wierd, since this error only occurs only on my Home PC and not at work. I don't even know if I want to solve this one :(

 

Edit: Solved this one by installing a Shared Service Provider. Instructions found here

Content Query Web Part - Anonymous users and ItemStyle.xsl

If you have modified the ItemStyle.xsl file (located in the Style Library) to change the way the Content Query Web part looks, remember to check it back in and publish a major version for anonymous users to see the changes.

 

I hope this post saves someone a couple of hours of hair pulling.

Visual Studio 2008 Standard Edition and Sharepoint 2007 State Machine and Sequential Workflow Templates

Curiously, the Sharepoint 2007 State Machine and Sequential Workflow Templates are missing in Visual Studio 2008 Standard Edition. I'm going to install the Enterprise Edition of Visual Studio because I know that they are present in them.

 It took a while to figure out they were missing, but finally when I checked "%ProgramFiles%\Microsoft Visual Studio 9.0\Common7\IDE\ProjectTemplates\CSharp\Workflow\1033" folder, the 'VSTOSharePoint2007WFSequential.zip' and 'VSTOSharePoint2007WFStateMachine.zip' files were missing

I guess they were excluded because they were part of the Office Development tools thats missing from the Standard Edition. Standard Edition users could try obtaining the above mentioned zip files, deploy them in the 1033 folder and see if the templates work. (Caution: It may be illegal to do so! So, do it at your own risk!)

Sharepoint bug: Installing SP2 will set expiration date to 180 days

This is not what we need right now.

From the Micrsoft Sharepoint Team blog:

During the installation of SP2, a product expiration date is improperly activated. This means SharePoint will expire as though it was a trial installation 180 days after SP2 is deployed. The activation of the expiration date will not affect the normal function of SharePoint up until the expiration date passes.
 
Furthermore, product expiration 180 days after SP2 installation will not affect customer’s data, configuration or application code but will render SharePoint inaccessible for end-users.
 
We are working to release a hotfix to automatically fix this issue. A manual work-around is currently available and involves customers re-entering their Product ID number (PID) on the Convert License Type page in Central Administration.  For more information and detailed steps please read this KB article.
 

Read more....

Hopefully, MS comes out with a hotfix really soon.

List Event Example Code

Sharepoint lets us tap into quite a substantial number of List Events. Some of them are:

SPEventReceiverType.FieldAdded;

SPEventReceiverType.FieldAdding;

SPEventReceiverType.FieldDeleted;

SPEventReceiverType.FieldDeleting;

SPEventReceiverType.FieldUpdated;

SPEventReceiverType.FieldUpdating;

SPEventReceiverType.InvalidReceiver;

SPEventReceiverType.ItemAdded;

SPEventReceiverType.ItemAdding;

SPEventReceiverType.ItemAttachmentAdded;

SPEventReceiverType.ItemAttachmentAdding;

SPEventReceiverType.ItemAttachmentDeleted;

SPEventReceiverType.ItemAttachmentDeleting;

SPEventReceiverType.ItemCheckedIn;

SPEventReceiverType.ItemCheckedOut;

SPEventReceiverType.ItemCheckingIn;

SPEventReceiverType.ItemCheckingOut;

SPEventReceiverType.ItemDeleted;

SPEventReceiverType.ItemDeleting;

SPEventReceiverType.ItemFileConverted;

SPEventReceiverType.ItemFileMoved;

SPEventReceiverType.ItemFileMoving;

SPEventReceiverType.ItemUncheckedOut;

SPEventReceiverType.ItemUncheckingOut;

SPEventReceiverType.ItemUpdated;

SPEventReceiverType.ItemUpdating;

 

Listening to an event is very easy, simply create a new class file, and create a class that derieves from the 'SPItemEventReceiver' class as shown below:

namespace SaturnVibes.EventsExample

{

    public class ListEvents : SPItemEventReceiver

    {

        static ListEvents()

        {

            // Add Static constructor code here....

        }

 

        public override void ItemAdding(SPItemEventProperties properties)

        {

            // Add Code to execute when an Item is being added

        }

 

        public override void ItemAdded(SPItemEventProperties properties)

        {

            // Add Code to execute after an Item has being added

        }

 

        public override void ItemUpdating(SPItemEventProperties properties)

        {

            // Add Code to execute when an Item is being updated

        }

    }

In the above code sample, we have created a class in which the list's 'ItemAdding', 'ItemAdded' and the 'ItemUpdating' events were overriden. We can now execute our code in these list events.

The SPItemEventProperties object, will give us the properties that the listitem will have, both before and after the the event. An important thing to note here from the above sample is that, in an 'ItemAdding' event, since the List Item has not yet been created, 'properties.ListItem' will be null. To retrieve the values that a user may have entered while creating a list item, use 'properties.AfterProperties["Internal Name of the List Column"]'. Remember to provide the internal name of the List column inside the '[]'. (See how to get the Internal name of a List Column)

If the List event needs to be cancelled, we can set the 'properties.Cancel' to true and provide an error message in the 'properties.ErrorMessage' property.

Eg:

properties.ErrorMessage = "Your error message";

properties.Cancel = true;

 

Before the above code can be used however, the List event has to be registered to look for our code sample whenever an event is fired. This is done by:

SPWeb spWeb = new SPSite("URL of Site").OpenWeb();

list = spWeb.Lists["List Name"];

list.EventReceivers.Add(eventType, assemblyName, className);

where,

eventType is an enum of 'SPEventReceiverType'. Eg: 'SPEventReceiverType.ItemAdding'

assemblyName is the entire name of the assembly

className is the name of the class containing the event reciever. Eg: SaturnVibes.EventsExample.ListEvents

 

Happy Sharepointing :)

Retrieve a List's LookupValue ListItem

When using a lookup value in a list column, we sometimes need the entire item that is being looked up, in addition to it's value. Here's how to do it:

SPSite spsite = new SPSite("http://SiteAddress")
SPWeb spWeb = spsite.OpenWeb();

// Remember to get the ListItem through your preffered method :)

// Use the  'SPFieldLookupValue' class to create an object......

SPFieldLookupValue lookupValue = new SPFieldLookupValue(listItem["Insert Column Name here"].ToString());

// Get the LookUp's List item's ID (which is of an integer datatype)

int itemID = lookupValue.LookupId;

// Get the LookupValue's List Item....
SPListItem lookupValueListItem = spWeb.Lists["ListName"].GetItemById(itemID);

// Get the value in the lookup.

// This might be of interest,

// because, using 'listItem["Insert Column Name here"].ToString()' gives us

// some unnecessary values like '#'.

string value = lookupValue.LookupValue;

 

So, now we have the LookupValue's list item in 'lookupValueListItem' and the lookup's value in 'value'.

 

Happy Sharepointing :)

Create a Sharepoint list through code

Here's an article to create Sharepoint Lists through code:

http://www.sharepointblogs.com/michael/archive/2009/05/15/how-to-create-a-sharepoint-list-programmatically.aspx

Workflow task OwnerActivityName

The task's CorrelationToken's OwnerActivityName decides the scope in which the task is controllable. When a workflow is in the same state as that of the OwnerActivityName state, the task can be modified/deleted safely.

If the OwnerActivityName is set to a state that is not the task's parent state, or is set to the root StateMachineWorkflow state, modification and deletion of the task may be locked by the workflow. Generally, the task's lifetime should only be in the scope of it's Owner state.

If a scenario arises, where a task has to be completed in another state, consider changing the state to the task's owner state, modify/delete the task and then jump to the necessary state.

Special characters not allowed in a Sharepoint filename

You cannot have the following characters in a filename for a file that is being uploaded onto Sharepoint:
~
#
%
&
*
{
}
\
:
<
>
?
/
|
"

A simple function to replace the special characters would be:

    public static string ConvertSpecialCharacters(string stringToConvert)
    {
        stringToConvert = stringToConvert.Replace("~", string.Empty);
        stringToConvert = stringToConvert.Replace("#", string.Empty);
        stringToConvert = stringToConvert.Replace("%", string.Empty);
        stringToConvert = stringToConvert.Replace("&", string.Empty);
        stringToConvert = stringToConvert.Replace("*", string.Empty);
        stringToConvert = stringToConvert.Replace("{", string.Empty);
        stringToConvert = stringToConvert.Replace("}", string.Empty);
        stringToConvert = stringToConvert.Replace("\\", string.Empty);
        stringToConvert = stringToConvert.Replace(":", string.Empty);
        stringToConvert = stringToConvert.Replace("<", string.Empty);
        stringToConvert = stringToConvert.Replace(">", string.Empty);
        stringToConvert = stringToConvert.Replace("?", string.Empty);
        stringToConvert = stringToConvert.Replace("/", string.Empty);
        stringToConvert = stringToConvert.Replace("|", string.Empty);
        stringToConvert = stringToConvert.Replace("\"", string.Empty);
    }

To use the above function, we would have to write an event handler for file upload and get the filename and then check and replace the special characters from the filename.

In addition to the above, there are a couple of other rules that a filename should follow. See here

Service Pack 2 for Microsoft Office Server 2007 released

Service Pack 2 for 2007 Microsoft Office Servers - Description here: http://support.microsoft.com/?kbid=953334

Download from: http://www.microsoft.com/downloads/details.aspx?FamilyId=B7816D90-5FC6-4347-89B0-A80DEB27A082&displaylang=en

Fixes for Project Server 2007 include:

Microsoft Office Project Server
  • Modifies the queue service to prevent it from using large volumes of memory over long periods.
  • Improves the performance of certain database table indexes.
  • Improves cost resource functionality. For example, the server now correctly handles tasks that have material or work resources assigned to the same task.
  • Improves certain areas such as resource plans, build team, and the server scheduling engine.