Friday, May 29, 2009

Property problems in SharePoint Search

Today I got the below error in SharePoint Search no matter what search string I was attempting to use...



"Property doesn't exist or is used in a manner inconsistent with schema settings."

After some investigation I come to know, the problem is due to a results schema, on search results page, which doesn't match the schema that you are using for your query. This occurred because someone had changed the 'Selected Columns' XML in the 'Search Core Results' Web Part.

The fix for the problem is,
  1. Go to the Search Results Page
  2. Go into Page Edit Mode
  3. Find the 'Search Core Results' Web Part on the page
  4. Modify the Web Part, and go to it's properties
  5. Expand 'Results Query Options'
  6. Go to 'Selected Columns' and edit this field.
Actually problem lies here property defines here is incorrect.

The XML, by default, should look something like:


Monday, May 18, 2009

Calling C# Method from Inline JavaScript

This Post will help in calling a C# method from Inline JavaScript.

Inline Javascript:

string strMessage = "Some message";
StringBuilder sb = new StringBuilder();
sb.Append("< language="'javascript'">"); //Remove the in between space of script tag
sb.Append("var results = confirm('" + strMessage + "');");
sb.Append("if (results == true)");
sb.Append("document.getElementById(\"btnHdn\").click();"); //call methodTrue
sb.Append(" < /" + "script >"); //Remove the in between space of closing script tag
this.RegisterStartupScript("startup", sb.ToString());

When "Ok" is clicked from Confirm dialog box. btnHdn button's Click event gets fired.

Note:

1. Define the button btnHdn as mentioned below,

< id="btnHdn" runat="server" onclick="btnHdn_Click">

2. Instead of making button Hidden, use the below properties to show & hide a button

btnHdn.Attributes["Style"] = "display:none"; //To Hide button
btnHdn.Attributes["Style"] = "display:block"; //To display button

Thursday, May 14, 2009

Creating Business Data Catalog Application

This Post helps us to Create Business Data Catalog Application from an Application Definition File. After that we will use that Business Data Catalog Application to drive the contents of a Web Part and a SharePoint list.

Prerequisites
a. You should have AdventureWorks Sample Database already installed with SQLServer2005.
b. You should have AdventureWorksDW.xml & AdventureWorks2000.xml Files in your system. You can get those from,
http://msdn2.microsoft.com/en-us/library/ms519241.aspx
http://msdn2.microsoft.com/en-us/library/ms494876.aspx
Copy & Paste the metadata in text files and save those as AdventureWorks2000.xml & AdventureWorksDW.xml files respectively.

Approach in Steps

Create the Business Data Catalog Application
1. Open AdventureWorks2000.xml & AdventureWorksDW.xml files.
2. Review the Contents of the Properties group of elements in the LobSystemInstance element.
3. In the LobSystemInstance metadata, replace the name of the computer running SQL Server that hosts the AdventureWorks2000 database in the Rdb Connection Source property accordingly. If you use a SQL Server instance, use the format, SQLServer\Instance e.g. son15824, if don’t have any instance.
4. Save & Close the xml Files.
5. Now Open Central Administration Web Page. Under Shared Services Administration, click SharedServices1.
6. On the Home Page of SharedServices1, under Business Data Catalog, click Import application definition.
7. From here Import those AdventureWorks2000.xml & AdventureWorksDW.xml application definition files.




Add Business Data List Web Part

1. Add a Business Data List Web Part to the home page of your portal site & Click the Open the tool pane link. In the Type section of Business Data List pane, select the appropriate Business Data Type e.g. Product.



2. Click OK and then Exit Edit Mode.
3. Test the Business Data List Web Part.


Create a Data-Driven Custom List

1. Create a Custom List from Custom Lists section & give it a name e.g. ProductInfo List.
2. On the ProductInfo List page, on the setting menu, click Create Column & give it a name e.g. ProductDetails.
3. Under The type of information in this column is, click Business Data.
4. In the Additional Column Settings section, under Type, provide the appropriate business data type e.g. Product by clicking on Browse button.
5. In the Display this field of the selected type list, click Name.
6. Under Add a Column to show each of these additional fields, Select the Color and the Size check boxes, and then click OK.
7. Now on the ProductInfo List page, create a New Item & provide the necessary information. Click the OK button.



8. A New item is created based on data retrieved from the Business Data Catalog application.

Monday, May 11, 2009

Creating Custom Content Types

1. Create blank word document, excel sheet and power point.
2. Save it in on desktop or any other place with extension as template.
3. Go to the home page of your portal and click on Site Actions.
4. In Site Actions, click on Site Settings.
5. Under Galleries, click on Site Content Types.
6. Click on create.
a. Write the name of your default document.
b. In parent content type form, select special content types.
c. Click radio button of new group and write the group name.
d. Click on ok.
7. In settings, click on Advanced settings.
a. Upload a new document template by clicking on browse. Click ok.
8. Repeat the steps 6 and 7 for other documents by going into Site Content Type Galleries. Add them in the same group that you mentioned for the word document.
9. Go to home page and click on shared documents on your page and then click on settings and then document library settings.
10. Under general settings, click on Advanced settings.
11. Under Allow management of content types? Click yes and then press ok.
12. Under content types, click on Add from existing site content types.
13. Select your group name and add the blank documents given in the box below. Click ok.
14. Go back to your shared documents, and click on new. You will find your blank word document,

Creating Custom Site Definition in MOSS 2007

The new version of SharePoint brings some changes to the way Site Definitions are created and deployed to a SharePoint server. Additionally, the way Site Definitions are now architected has changed with the advent of Features. Although FrontPage 2003 has been significantly enhanced to become the Office SharePoint Designer, Features allow for more flexible deployments of functionality within SharePoint, and Master Pages allow us to change the look and feel of many sites inside SharePoint with a single click of a button - custom Site Definitions can still be leveraged to provide outstanding enterprise wide flexibility and ease of maintenance for SharePoint sites.
Site Definitions are a complex and large topic that we will not delve into in an in depth manner right now. The purpose of this post is to describe how to create a custom Site Definition in order to set the stage for the other documentation.

Site Definition basics

Site Definitions are located in the following folder on the SharePoint server:
C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\SiteTemplates
Each Site Definition has its own sub directory under this folder.
Inside each Site Definition sub directory the aspx pages for the various web pages and lists that make up the Site Definition are stored. The ONET.XML file that specifies the various configurations and modules the Site Definition is made up of is stored inside the XML subdirectory inside each Site Definition sub directory.
*Note: I think it is interesting that the SDK refers to Site Templates as the .stp files that are generated when you save a site as a template from the web UI, and the SDK refers to file based site templates as Site Definitions – yet this directory is named SiteTemplates.
Site Definitions are registered with SharePoint and made available via the WEBTEMP.XML file.
These files are located in the following folder on the SharePoint server:
C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\1033\XML

Creating a custom Site Definition in MOSS 2007

The following tasks are all you need to do to create a custom Site Definition in MOSS 2007.
Step 1: Clone an existing Site Definition.
Step 2: Create the WEBTEMP XML fragment file to register the Site Definition with SharePoint.
Step 3: Reset IIS
Step 4: Create a site based on the custom Site Definition.

Step 1: Clone an existing Site Definition.

Navigate to the following directory on the SharePoint server in Windows Explorer:
C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\SiteTemplates
Copy the STS directory and paste it back into the same directory.
Rename the Copy of STS directory to SAMPLE
Navigate to the following directory on the SharePoint server in Windows Explorer:
C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\1033
Copy the STS directory and paste it back into the same directory.
Rename the Copy of STS directory to SAMPLE

Step 2: Create the WEBTEMP XML fragment file to register the Site Definition with SharePoint.

Create a file called WEBTEMPSAMPLE.XML in the following directory:

C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\1033\XML

Put the following XML into the WEBTEMPSAMPLE.XML file:

*Note: The DisplayCategory attribute of the <> element dictates which tab the configuration will appear on in the Template Selection section of the create site web page. You can create your own tabs by putting your own values in this attribute (like we have done here).

Save the file.

Alternate Approach

(You can also Copy & Paste WEBTEMP.XML & Rename that as WEBTEMPSAMPLE.XML & Change the template section)

Step 3: Reset IIS

Open a command prompt on the SharePoint server.

Type in the command: iisreset

Wait for IIS to reset

Step 4: Create a site based on the custom Site Definition.

Open Internet Explorer

Navigate to the Sites Directory in your SharePoint portal (http://SharePointServerName/SiteDirectory)

Click the Create Site Link

Fill out the information on the form.

Notice at the bottom of the page in the Template Selection section the new Custom Site Definitions tab.

Click this tab and select one of the available configurations.

Click the Create button.




Friday, May 8, 2009

Manual Record Routing in MOSS

When a document is sent to the records center, it is routed to its final destination (a document library) by means of the routing table in the Records Center.
The standard MOSS routing routes records based on their content type to a specified document library. Many different content types can be routed to a single document library.
Approach in Steps
1. Create a Site using team site template.
2. Click on site actions, go to site settings then site content types. Create three new site content types as Admin, Sales and Marketing.




3. Create a common document library so that documents can be created/uploaded here by the users.



4. Go to the “Document Library Settings” of this common library and go to “Advanced Settings” check “yes” for management of content types. This will allow giving the content type while creating/uploading a document.



5. Now create a new site under the site collection using record center site template. This will allow managing our records.

6. In Central Admin go to “Application Management” then “Records Center” in “External Service Connections” check the connect to record center radio button. Specify URL of your record center site as http://server/portal/_vti_bin/officialfile.asmx in the URL field like:

“http://son15824:3333/records/_vti_bin/officialfile.asmx”. Give some display name.




7. In the records center site one can see Unclassified Documents. Documents that are uploaded without mentioning the content type will be placed here.



8. Create three new document libraries as for this example Admin Docs, Sales Docs and Marketing Docs.

9. In Record routing table create three new items as AdminRec, SalesRec and MarketingRec. While creating these items, in the location field, specify the name of an existing document library into which you want to send the documents (This Document Library should be on the same Record Center Site). The aliases field will decide the content type of the documents that the library should have. Simply the record routing items define rules about how to route documents into libraries.




10. Now upload any document in the common document library and fill the required data like name, title and content type.



11. Open the common document library. Right click on the document, we can see Send To option. Using this we can send that document to our records center.


Creating Themes in Moss 2007

1. On the SharePoint server go to the Themes folder e.g. c:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\Themes

2. Make a copy one of the existing theme folders and its contents rename it e.g. MyTheme.

3. Rename the .INF file within the MyTheme folder to MyTheme.INF

4. Edit MyTheme.INF.

a. At the info section, Change the title, to MyTheme. Change codepage, e.g. 22200, replacing the code page will fix error “A theme with the name “MyTheme 1011? and version already exists on the server.”

b. In the titles section, rename the names to your new name. This section is to present the name in the different language.

5. Provide an image to give a preview of your theme. This image should be placed in C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\IMAGES. E.g. tmbMyTheme.gif

6. Modify the c:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\Layouts\1033\SPTHEMES.xml to include a reference to the new MyTheme theme

7. Modify the CSS within MyTheme folder to personalize your theme.

8. Run iisreset from the command prompt.

9. Apply the new theme to a “test site”.