While creating a new page in a collbartion portal, you might come with this error.
This ContentTypeID points to the "PublishingResources" feature.
You will need to activate this feature by running STSADM. The command is
STSADM -o activatefeature -name PublishingResources -url http://MOSS_URL
Monday, June 23, 2008
Fix for Content type '0x01010007FF3E057FA8AB4AA42FCB67B453FFC100E214EEE741181F4E9F7ACC43278EE811' not found
Posted by Sanjay Sansanwal at 1:34 pm 3 comments
Tuesday, April 15, 2008
SharePoint administrative and development Tool
SharePoint SUSHI
SUSHI is a powerful, user-friendly SharePoint application enabling you to accomplish common SharePoint administrative and development tasks. You can think of SUSHI as a Swiss army knife for SharePoint.
What does the name SUSHI stand for?
SUSHI = SharePoint Utility with a Smart, Helpful Interface
Link
Posted by Sanjay Sansanwal at 4:16 pm 0 comments
Wednesday, April 09, 2008
Display raw XML returned by SharePoint Search
On Search page, modify the XSLT of "Search Core Results" web part to
#?xml version="1.0" encoding="UTF-8"?>
#xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
#xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
#xsl:template match="/">
#xmp>
#/xsl:template>
#/xsl:stylesheet>
Replace # with <
Posted by Sanjay Sansanwal at 12:39 pm 0 comments
Thursday, April 03, 2008
NumberToWord Function
| private string[] _englishDigitMatrix = new string[]{"", "Second", "Third", "Fourth","Fifth", "Sixth", "Seventh", "Eighth","Nineth"}; public string changeNumericToWords(int number) { string ret = _englishDigitMatrix.GetValue(number - 1).ToString();return ret; } |
Posted by Sanjay Sansanwal at 10:52 am 0 comments
Labels: Dot NET
Wednesday, April 02, 2008
Using Database Mirroring with Office SharePoint Server and Windows SharePoint Services
Database mirroring is a new technology in Microsoft® SQL Server™ 2005 database software that can deliver high availability and high performance solutions for database redundancy. In database mirroring, transactions are sent directly from a principal database and server to a mirror database and server whenever the principal database’s transaction log buffer is written to disk. This technique can keep the mirror database nearly up to date with the principal database. You can optionally use a third server, a witness server, to enable automatic failover from the principal server to the mirror server.
The update includes more prescriptive information on the type of supported topologies. It also recommends SQL connection aliasing for failover within a farm.
http://go.microsoft.com/fwlink/?LinkId=83725&clcid=0x409
Posted by Sanjay Sansanwal at 10:49 am 0 comments
Labels: MOSS
SharePoint Branding Tool (Themes, Master pages, Site Logos...)
This tool can be used apply the following actions for multiple Site Collections, and Child Sites:
modify Themes
modify MasterUrl (Master Page)
modify CustomMasterUrl (System Master Page)
modify SiteLogoUrl (Site Logo)
modify SiteLogoDescription (Site Logo Alternative Text)
modify AlternateCssUrl (Custom CSS Style Sheet)
view various properties of sites and themes at a glance
Selection of sites can be filtered by the Site Template used.
http://www.codeplex.com/BrandingTool
Posted by Sanjay Sansanwal at 10:47 am 0 comments
Labels: MOSS
Tuesday, April 01, 2008
Add and display Custom Column in SharePoint Search Result
The results in SharePoint Search are displayed by Search Core Results Web Part. This web part have “Selected Columns” property under “Results Query Options” category which contains an XML string that defines all of the columns that are to be displayed in the search results.
The following is the default list of columns shown in the search results:
Now, we will create a new mapped property named “ListItemId”. Managed properties map to one or more of the crawled properties. They group together the related crawled properties and expose them to the user
The Search Settings in the administrative site of the Shared Services Provider has a Metadata Property Mappings link. Clicking on it brings you to the Metadata Property Mappings page
Now, click on “New Managed Property”
Enter, the property name as: “ListItemId” and make sure you select “Integer” and “Allow this property to be used in scopes”
Note: By default “Type of Information “is set to Text
Now, you need map to the crawled properties. The Add Mapping button pops up a dialog box where you can navigate through all of the crawled properties and select the ones you want to map to the managed property
Enter ows_id and press Find, select the property and click OK.
Note: If you didn’t selected “Type of Information “as Integer, SharePoint is not able to search this property.
Now, start a full Crawl of your content and you should now see your List Item in search results
Posted by Sanjay Sansanwal at 3:53 pm 0 comments
Labels: MOSS
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
Posted by Sanjay Sansanwal at 4:56 pm 0 comments
Labels: MOSS
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
Posted by Sanjay Sansanwal at 4:18 pm 0 comments
Labels: MOSS
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
Posted by Sanjay Sansanwal at 10:47 am 0 comments
Labels: Dot NET
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
Posted by Sanjay Sansanwal at 11:57 am 0 comments
Labels: MOSS
"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
Posted by Sanjay Sansanwal at 11:48 am 1 comments
Labels: MOSS
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;}
}
Posted by Sanjay Sansanwal at 4:06 pm 0 comments
Labels: Integration
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;
Posted by Sanjay Sansanwal at 3:43 pm 0 comments
Labels: MOSS
Wednesday, February 20, 2008
Start a SharePoint workflow using code
Imagine you already have a SharePoint list with thousands of items and now want to associate a custom workflow with the list.
How will you go and run Workflow on all the existing items as Microsoft SharePoint don't provide any option to run workflow on existing items.
The solution: Run the workflow against each list item via the code
First Get the Workflow Guid and then Create a workflow association object. Start the workflow from the site passing the list item and the workflow association object.
To get a workflow Guid:
Go to List Settings- Workflow Setting and click on the workflow. From URL get the targetId value.
Create a Visual Studio 2005 Console project
Add Reference to SharePoint Library
Replace content of program.cs with the following code--
using System;
using System.Collections.Generic;
using System.Text;
using System.Configuration;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Workflow;
using System;
using System.Collections.Generic;
using System.Text;
using System.Configuration;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Workflow;
class Program
{
static void Main(string[] args)
{
try
{
Console.WriteLine("Started...");
Console.WriteLine("Read value from config list");
// Read from App.Config file
// Site URL
string SiteName = ConfigurationManager.AppSettings["SiteName"];
// Workflow Guid
string WorkFlowGuid = ConfigurationManager.AppSettings["WorkflowGuid"];
// List Name
string ListName = ConfigurationManager.AppSettings["ListName"];
// Query used to filter the items on which WorkFlow needs to be run
string Query = ConfigurationManager.AppSettings["Query"];
// Get Html Decoded Guid
string decode = ConfigurationManager.AppSettings["DecodeGuid"];
if (decode == "1")
WorkFlowGuid = DecodeString(WorkFlowGuid);
Console.WriteLine("Read site details");
SPSite site = new SPSite(SiteName);
SPWeb web = site.OpenWeb();
SPList list = web.Lists[ListName];
Console.WriteLine("Read workflow details");
SPWorkflowAssociation workflowAssociation = list.WorkflowAssociations[new Guid(WorkFlowGuid)];
Console.WriteLine("Get items");
SPListItemCollection items = null;
if(Query.Length > 0) // filtered
{
SPQuery query = new SPQuery();
query.Query = Query;
items = list.GetItems(query);
}
else
items = list.Items; // all items
Console.WriteLine("Looping items");
foreach (SPListItem item in items)
{
if(item.Workflows.Count == 0)
{
// Start if already not started
site.WorkflowManager.StartWorkflow(item, workflowAssociation,
workflowAssociation.AssociationData, true);
}
}
Console.WriteLine("Done");
}
catch (Exception ex)
{
Console.WriteLine("Error: " + ex.Message);
}
finally
{
Console.WriteLine("Press any key to exit...");
Console.ReadLine();
}
}
static string DecodeString(string sStr)
{
string sChars = " ,',!,#,$,%,&,(,),/,:,;,[,\\,],^,`,{,|,},+,<,=,>,-";
string sANSICodes = "+,%27,%21,%23,%24,%25,%26,%28,%29,%2F,%3A,%3B,%5B,%5C,%5D,%5E,%60,%7B,%7C,%7D,%2B,%3C,%3D,%3E,%2D";
string[] aChars = sChars.Split(",".ToCharArray());
string[] aANSICodes = sANSICodes.Split(",".ToCharArray());
for (int i = 0; i <= aChars.GetUpperBound(0); i++)
{
if (sStr.IndexOf(aANSICodes[i]) > -1)
sStr = sStr.Replace(aANSICodes[i], aChars[i]);
}
return sStr;
}
}
********************Config File*********************
*****************************************
The code logic-
Read values from the app.config file
If WorkflowGuid is encoded as in the config file, decode the Guid
Get workflowassociated with this WorkFlowGuid
Based on SharePoint Query, get the items
Loop through the items and if no workflow started for that item. Start the workflow
Posted by Sanjay Sansanwal at 2:34 pm 1 comments
Labels: MOSS
Monday, February 18, 2008
Singleton Class WinForm\WebForm
If you use static object in ASP.NET application, this works as Application object and is shared across all sessions. To create a user visible properties, we use session objects. A better way of using this is to use Singelton class. This class creates only one object and same object is refeneced again without new creation. The following code could be used to create a common Singleton class for windows and web application.
using System;
using System.Data;
using System.Configuration;
using System.Web;
namespace Common
{
///
/// Summary description for SessionConfig
///
public class StateData
{
#region PROPERTIES
string currentUser;
public string CurrentUser
{
get { return this.currentUser; }
set { this.currentUser = value; }
}
#endregion
private static StateData oInstance;
protected StateData()
{
}
public static StateData Instance
{
get
{
// If called from windows, this would be null. Use Static object then
if (System.Web.HttpContext.Current == null)
{
if (oInstance == null)
{
oInstance = new StateData();
}
return oInstance;
}
if (HttpContext.Current.Session == null || HttpContext.Current.Session["SharedData"] == null)
HttpContext.Current.Session.Add("SharedData", new StateData());
return (StateData)System.Web.HttpContext.Current.Session["SharedData"];
}
}
}
}
Posted by Sanjay Sansanwal at 12:05 pm 0 comments
Labels: Dot NET
Hide\Show Column in Sharepoint Form
You don't need desugner to hide or show a column in Display, Edit and New form of Sharepoint List. You could use Sharepoint Objects to set this programmatically-
Create a console application and Reference SharePoint Library-
The code will be
SPSite site = new SPSite(SiteName);
SPWeb web = site.OpenWeb();
SPList list = web.Lists[ListName]; // Get teh list
// Colname = Column to hide\show
list.Fields[ColName].ShowInEditForm = ShowInEditForm;
list.Fields[ColName].ShowInDisplayForm = ShowInDispForm;
list.Fields[ColName].ShowInNewForm = ShowInNewForm;
list.Fields[ColName].Update();
Posted by Sanjay Sansanwal at 11:57 am 2 comments
Labels: MOSS
Wednesday, October 18, 2006
Webresource.axd or WebForm_PostBackOptions undefined problem
If would get this error if you are missing reference to Webresource.axd file.
Create an empty file with name as "Webresource.axd" and copy it to web server wwwroot and your application root folder.It should work now.
Posted by Sanjay Sansanwal at 12:00 pm 0 comments
Labels: Dot NET
Friday, June 02, 2006
SelectALL in Compact Framework
When you want to select all the text in a textbox, you are more likely to use SelectAll function of the textbox in the GotFocus event. Ironically, once this event is fired the text is unselected. The work around is to use a timer and in timer event call SelectAll function.
private void textBox1_GotFocus(object sender, EventArgs e)
{
//Use a timer to select all
System.Windows.Forms.Timer t = new System.Windows.Forms.Timer();
t.Interval = 10;
t.Tick += new EventHandler(t_Tick);
t.Enabled = true;
}
}
///
/// Event to select full text in textbox
///
///
///
private void t_Tick(object sender, EventArgs e)
{
((System.Windows.Forms.Timer)sender).Enabled = false; // Stop the timer
// Select all the text
textBox1.SelectAll();
}
Posted by Sanjay Sansanwal at 12:02 pm 0 comments
Labels: Dot NET
