Wednesday, December 29, 2010

InfoPath Form Error Messages "Updating content type failed" & "The following location is not accessible, because it is in a different site collection"

Deployment Steps we followed in Production Server

1. We took Backup of INFOPATH SITE using STSADM command
2. Downloaded template from Site Document Library (Reviews Document Library > Settings > Advanced Settings > Document Template > SITE Reviews/Forms/template.xsn).

3. While Publishing we promoted and de-promoted columns as per the as per column promotion requirement. But we got two error message when try to publishing the InfoPath Form template.

Error Message 1: "Updating content type failed"
Error Message 2: "The following location is not accessible, because it is in a different site collection: http://Servername/sites/SiteName/InfoPath_Library_Name/Forms/template.xsn"”.


Solution for the error message:

Need to Upgrade InfoPath Service Pack2 & Security Upgrade and information as below

1. Update for Microsoft Office InfoPath 2007 (KB976416)
URL: http://www.microsoft.com/downloads/en/details.aspx?FamilyID=79cc0c0f-6d2f-4a55-ad6f-7fd6bfa61896&displaylang=en

2. The 2007 Microsoft Office Suite Service Pack 2 (SP2)
URL: http://www.microsoft.com/downloads/en/details.aspx?FamilyId=B444BF18-79EA-46C6-8A81-9DB49B4AB6E5&displaylang=en

3. Security Update for Microsoft Office InfoPath 2007 (KB979441)
URL: http://www.microsoft.com/downloads/en/details.aspx?familyid=bfa8765a-7970-4feb-996c-7c27d71c97c6&displaylang=en

Wednesday, December 15, 2010

Could not load XSL file. The system cannot find the file specified. (Exception from HRESULT: 0×80070002) Content By Query Web Part or TableContentsWeb

We recieve this error while trying to edit ContentByQueryWebPart or TableContentsWeb.

The reason for this error is because the publishing features are not enabled for the site.
So we need to enable the publishing features.

For this first activate Office Sharepoint Server Publishing Infrastructure feature found at
Site Collection Administration – Site Collection Features.

Than enable Office Sharepoint Server Publishing feature at Site Administration- Site features

Tuesday, December 14, 2010

How do I Check in Multiple Documents With Sharepoint Designer?

Instructions

1. Start "SharePoint Designer" by clicking "Start" and highlighting "All programs" and then select "Microsoft Office" and click on "Microsoft Office SharePoint Designer."

2. When "SharePoint Designer" opens click on "File" and select "Open site." On the open site dialog box in the "Site name" box type the address there as if you were navigating to your SharePoint site in a browser and click on "Open."

3. This will open the site through "SharePoint Designer" in a tree view which is where all of the files, folders and sites are shown in the left-hand pane. Here you will see the "Document folders" as well, double-click on the folder that holds the documents and it will open the folder contents in the large center pane.

4. Drill down to the specific folder that holds the files you uploaded. Next to each folder you will see a "Green arrow" pointing down, and to the right it indicates the file is checked out. If you wish to check in multiple documents at once hold down the "CTRL" key and click on each file to highlight the files.

5. Right-click just "One" of the highlighted files and the sub-menu will pop up, select the option that says "Check in" and it will go through file by file and check them in. Once they have been checked in the "Green arrow" that was previously there will now be gone.

6. If you copy a whole folder to a "SharePoint site" you can go into "SharePoint Designer" and navigate through the sites and folders to the exact folder you copied just as you did before to check in multiple files, and this time right-click the "Folder" you copied and select "Check in." Just like the multiple files, it will process and check in each file. To verify this you will need to navigate into the folder to make sure that all of the "Green arrows" are gone.

Tuesday, December 7, 2010

Using SQL QUERY to Find Out Site Created & Last Access Date

SQL QUERY:

Use Content Database Name

GO

SELECT FullUrl AS 'Site URL', TimeCreated,
DATEADD(d,DayLastAccessed + 65536, CONVERT(datetime, '1/1/1899', 101))
AS lastAccessDate FROM Webs WHERE
(DayLastAccessed <> 0) AND (FullUrl LIKE N'sites/%') ORDER BY lastAccessDate

Monday, November 29, 2010

Creating & Adding an Event Handler

In this document, we will create an event handler that captures the events of the document library and add an entry in the cell of the document added. We can add an event handler using code or as a feature. In order to write an event handler, we will first create a sharepoint site and create a document library. We will, then, capture the events of the document library.




b1-1



1 Writing an Event Handler


We will start from the Visual Studio 2005 new project window. In the new project window, select C# Window application, then, class library as encircled in the figure below and name the project “DocLibEventHandler”.




2.jpg



1.1 Adding Reference


The first thing we will do in the class library is to add reference of the name space Microsoft.SharePoint. This is done by right clicking on the References link in the solution explorer and then clicking on “Add Reference…” as encircled in the following figure:



3.jpg


Clicking on add reference will generate a new pop up window Add Reference. We will select the Windows® SharePoint® Services namespace, as encircled in the figure below, and click on OK. It will add the Windows® SharePoint® Services namespace in our project.



4.jpg




We will add the names spaces, encircled red in the figure below, in our project so that we can directly use the classes in that namespace without specifying the complete path.






5.jpg




1.2 Changing Class Name


We will again go to the solution explorer and change the name our class from “Class1” to “DocLibEventHandlerClass”. This can be done by clicking on the class name in the solution explorer and right click on the class name. This will open a new window from which we will select Rename and change the class name from “Class1” to “DocLibEventHandlerClass”. As you change the name of the class, a prompt will appear, shown in the figure below, and ask would you like to rename all references to the code element “Class1”? Click on “Yes”



6.jpg



1.3 Inheriting Class


We will inherit our class from the class SPItemEventReceiver. The path to the class SPItemEventReceiver is Microsoft.SharePoint.SPItemeventReceiver. We have already added the namespace Microsoft.SharePoint, therefore, we just writet the name of the class SPItemEventReceiver for inheritance as shown in the figure below:



5.jpg



1.4 Capturing Events


MOSS provides two types of events namely, synchronous and asynchronous. The “…ing” event occurs before the action starts and the “…ed” occurs after the actions ends. “…ing” events occur synchronously while the “…ed” events occur asynchronously.


8.jpg


Synchronous events



  • Occur before the event.

  • Block the flow of code execution until your event handler completes.

  • Provide you with the ability to cancel the events resulting in no after event (“…ed”) being fired.


Asynchronous events:



  • Occur after the event.

  • Do not block the flow of code execution in SharePoint


To capture these events, class SPItemEventReceiver provides different methods, as shown in the right side of the above figure, which can be seen through Object Browser by pressing Alt+Ctrl+j to see the list of the methods by browsing through Microsoft.SharePoint to SPItemEventReceiver. We will create a simple program for demonstration purpose. The code will override methods ItemAdding, ItemAdded, ItemUpdated and ItemUpdating in the class SPItemEventReceiver.


1.5 The Code


The code will run when a new file is added in the document library and also when an existing document is updated. It will add an entry in the list “CEO Docs Access Log” describing the nature of the event and date on which event occurred. The code is as under:


namespace DocLibEventHandler


{


public class DocLibEventHandlerClass : SPItemEventReceiver


{


public override void ItemAdded(SPItemEventProperties properties)


{


SPListItem doc = properties.ListItem;


doc["Comments"] = “Document has been added”;


doc.Update();


}


//you can use following methods as well


public override void ItemAdding(SPItemEventProperties properties) { }


public override void ItemUpdated(SPItemEventProperties properties) { }


public override void ItemUpdating(SPItemEventProperties properties) { }


}


1.6 Signing the Assembly


The next step is of signing the assembly. To do this, you have to move to the properties window of the project. To do this, right click on the project name “DocLibEventHandler” in the solution explorer and click on the properties in the popup menu. This will open the properties window, select the Signing Pane of the properties window and check the “Sign the Assembly” option. Select <New…> from the “Choose a strong name key file:” and give the name that you desired. In our case, we named it “DocLibeventAssembly” as shown in the figure below:



9.jpg




1.6 Build Project


We will build by pressing F6 or clicking on Build in the tolls menu and then clicking on Build Solution. Build will generate the file “DocLibEventHandler.dll” in the debug directory.


1.7 Copying into GAC


The file DocLibeventHandler.dll can be found in the debug folder whose path is C:\…..\Visual Studio 2005\DocLibEventHandler\DocLibEventHandler\bin\Debug. Depending upon your installation, you can find the file in the debug folder. Copy the file “DocLibeventHandler.dll” from this folder and paste it in the GAC folder which is normally found at C:\WINDOWS\assembly. After copying the file in the GAC, copy the public token key as encircled in the figure below:



10.jpg



There are many other ways of adding assembly in GAC.



1.8 Registering the Event Handler


In order to register the event handler, add a new console project in the solution by right clicking on the solution “DocLibEventHandler” in the solution explorer as shown in the figure below:



11.jpg



Select a console project in the “Add New Project” window and name it “DocLibRegApp” as shown in the figure below:



2.jpg



Add the following code in the main method.


namespace DocLinRegApp{


class Program {


static void Main(string[] args) {


SPSite sp = new SPSite(“http://servername”);


SPWeb website = sp.OpenWeb();


SPList DocLib = website.Lists["DLOne"];


string assm = “DocLibEventHandler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1d6b41a3ed9a92cb”;


string class = “DocLibEventHandler.DocLibEventHandlerClass”;


DocLib.EventReceivers.Add(SPEventReceiverType.ItemAdded, assm, class);


DocLib.EventReceivers.Add(SPEventReceiverType.ItemAdding, assm, class);


DocLib.EventReceivers.Add(SPEventReceiverType.ItemUpdating, assm, class); DocLib.EventReceivers.Add(SPEventReceiverType.ItemUpdated, assm, class);


}


}


}


The string assm describes the assembly details that we have added in the GAC and class is the name of our class. Press F5 to run the project.


1.9 Changes in the Document Library


Open the site and add document in the document library. Comments column will have the value “Document has been added” as shown in the figure below:





13.jpg


SharePoint 2007 - Orphan Sites

I was working with alongside one of the guy's from Microsoft the other day and we were implementing the MS IT Site Delete Capture Utility available from Codeplex. Part of the testing required me to create/delete & restore sites. Briefly, the site delete capture utility intercepts both site/web delete requests and archives the site/web. Having deleted the site from within Site Settings of the site. I then attempted to restore the site using STSADM at which point I was presented with an message telling me that the site collection already existed and that I should use another name. Ive just deleted it so that cant be right, so i immediately navigate to Central Administration and surprisingly the offending site is still there. I then try to delete the site from within Central Administration page but again it would not delete. Finally, I try to delete the site with STSADM but I got this error with stsadm.exe -o deletesite: The system cannot find the path specified. (Exception from HRESULT: 0x80040E2F). Not sure at this point if this is as a result of implementing the site delete feature, I look at the Event logs, ULS and the log that is provided with the site delete feature. Nothing indicated that the site delete feature was at fault.

A quick search and I learn of a term called "Orphan Sites". As it happens, orphan sites are not that uncommon and Microsoft had previously worked on a fix. It seems however that in some cases this issue can still occur but what Microsoft have done is provide some pretty cool STSADM operators to help resolve it, if it does occur.

An Orphaned Site is where SharePoint only has partial information and not a complete set of data for a given site collection in your Windows SharePoint Services or SharePoint Portal Server content databases or configuration databases. The site may in fact still be viewable via the browser, but you may notice that many things are broken.

An orphaned site may manifest itself in one of the following:

  • STSADM -o restore fails to restore the site, even with the -overwrite option when you know the URL exists.
  • You may receive an error code 0x80040E2F. 0x80040E2F means “Violation of PRIMARY KEY constraint”, this equates to STSADM already finding previous rows in the database for the items it's trying to restore.

    NOTE: STSADM first looks at the Configration and Content Databases to ensure that the site does not already exist, if it does and you didn't use the -overwrite switch, it will fail. If STSADM does not find any information, it begins restoring which then results in the problem noted above.

  • STSADM -o deletesite fails to delete the site
  • You may receive and error which states "The site does not exist". Again, No site information in Configuration or Content database in their respective Sites tables. Thus the other remnants of the site cannot be cleaned up.

To resolve this issue you must carry our the following 2 actions:

STEP 1

  1. Open a command prompt and go to change directory to C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN and type the following:

    stsadm -o databaserepair -url http://Web/sites/Site -databasename <DatabaseName> (This will list all sites that are orphaned)

  2. Next, type the following:

    stsadm -o databaserepair -url http://Web/sites/Site -databasename <DatabaseName> -deletecorruption

  3. You will then be presented with a result in xml format with a deleted attribute that equals to YES

    <OrphanedObjects Count="22"><Orphan Type="SPSite" Id="{E732BEEC-F4BD-40D7-A51F-7B33BA7D5698}" Deleted="Yes" />

STEP 2
  1. Launch SharePoint Central Administration.
  2. Select Application Management and under SharePoint Web Application Management select Content Databases
  3. Select the Content Database where the offending site remains.
  4. Make a note of the following settings:

    • The name of the Content Database.
    • The number of sites before a warning is sent.
    • The maximum number of sites setting.
    • The Windows SharePoint Services Search Server.

  5. Click to select the Remove content database check box, and then click OK. When you are prompted to confirm that you want to remove the content database, click OK.
  6. Click OK.
  7. On the Manage Content Databases page click Add a content database.
  8. On the Add a Content Database page, specify the database server, the database name, and the database capacity settings. Then, click OK.
  9. Once you have dont that, select the Content Database you have just re-added and ensure you select the Windows SharePoint Services Search Server noted earlier.
Having done that you should now be able to restore/recreate a site with the old name.

For further reading try the following Sharepoint Orphans Explained

Friday, November 26, 2010

Server error: http://go.microsoft.com/fwlink?LinkID=96177

While trying to install WSS 3.0 SP1 (http://technet.microsoft.com/en-us/office/sharepointserver/bb735839.aspx) the installation get stuck at task 9 of 10 of SharePoint Products and Technology Configuration Wizard. When tried to access the server,
encountered the following error:

Server error: http://go.microsoft.com/fwlink?LinkID=96177

When look into the “Event Viewer”, found the following error description:

The schema version (3.0.149.0) of the database DATADATABASE_NAME on DATABA_SESERVER_NAME is not consistent with the expected database schema version (3.X.X.X) on DATABASE_NAME. Connections to this database from this server have been blocked to avoid data loss. Upgrade the web front end or the content database to ensure that these versions match.

Resolution:

The first thing we did was either remove content database from the web application which are having the error or Detach the database. This doesn’t seem to work. So we run the command

stsadm –o upgrade –inplace –url Central_Administration_URL –forceupgrade

and we were back in the business J.