Wednesday, March 26, 2008

Use of Today field in SharePoint Formula

You can't use Today field in Sharepoint calculated field. The workaround is:

Create a custom column named "Today" with type as Date
Now, create a custom field and use above created field in formula
Delete the above created "Today" field.

The Sharepoint will work fine as it start using inbuild Today value for the formula

Install SharePoint workflow without MSI

To install a custom workflow developed using Visual studio, follow the steps given below-

-- Build your assembly
Drag and drop assembly to C:\Windows\Assembly. Right click and select the properties. Note down the pubclickeytoken for your assembly

-- Create a Feature.xml



-- Create a Workflow.xml



Change Association_FormURN based on your InfoPath Properties


-- Create a feature in SharePoint

Create a folder say "CUSTOM_WORKFLOW" in "C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATES\FEATURE"
Copy workflow.xml and feature.xml to this folder

-- Install and Activate the feature

Create a batch file with following content in your FEATURE folder
@ECHO OFF

ECHO.
ECHO Activiating and installing the feature...
ECHO.

SET STSADMDIR="C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN"

%STSADMDIR%\STSADM.EXE -o installfeature -filename CUSTOM_WORKFLOW\feature.xml -force
%STSADMDIR%\STSADM.EXE -o activatefeature -filename CUSTOM_WORKFLOW\feature.xml -url http://SHAREPOINT_URL

ECHO.
ECHO Resetting IIS
ECHO.

IISRESET

-- Run the batch file

Hurry, you could now see your workflow in Workflow settings of List

Thursday, March 20, 2008

Testing XSLT using VS2005

In past, I use to write code using XMLTransform to test an xslt. I found a better way last night, where you could use ASP.NET 2.0 XML control.
Steps:
Create a new ASP.NET web application using VS2005
Add your source xml file to the project
Add a new xslt file to the project using ADDITEM
On the default page, add the XML control from the toolbox
Set the TransformSource property of xml control to xml file
Set the TransformSource property of xml control to xslt file

Make changes in the xslt file and run the web application and check the result

Wednesday, March 19, 2008

Failed to determine definition for Feature with ID

I recently replicated my development server from the production server where changes are done by end users using STSADM back and restore process.

When I tried to edit my search page on development machine, I got error "An unexpected error has occurred."
To diagnosis this, I look at the log file created at "C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\LOGS".
The error logged was “Failed to determine definition for Feature with ID 'd75b8655-0098-40ac-aad6-7578d9d93901'. Skipping this feature for element querying consideration.”

Search this feature ID on production server at location “C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES” and found that it is for old custom workflow which was still on Production as there are existing items using it. But this has been replaced with new one on development and as such was not found.

This error will also occur if you have an Enterprise license on Production and Standard on Development as there will be some of the feature not available on the Development

"Search Scope" not visible in SharePoint 2007

You created a new search scope in SharePoint 2007 using Shared Services Administration -> Search Settings -> Scopes and found that its not visible on the site.
This new scope NEED to be visible via the Site Settings. Go to your site collection, click on Site Actions -> Site Settings -> Search Scopes.
Click on "Display Group" and select the display scope


Wednesday, March 05, 2008

Expose Readonly public property of DataContract in WCF

To expose readonly property in WCF using DataContract, add DataMember to the private property

[DataMember]
private string name;

public string Name
{
get{ return name;}
}

SharePoint Web part error "Object reference not set to an instance of an object"

I was getting "Object reference not set to an instance of an object" error while previewing a web part in web part gallery area.
Found that web part's CreateChildControls function is called even when you are previewing. This function was throuwing an error as in the code accesssing value of current list item using SPContext.Current.ListItem.

Added the following code and it worked fine
base.CreateChildControls();
if (SPContext.Current.ListItem == null)
return;