Unexpected error when changing the Top Navigation

When I had all the problems with our Replicator, and after it was finally solved, it started replicating the map and navigation structure. I desperately tried to stop the replication because I could see that it was altering my Top Navigation which I don’t wanted. But the damage was already done, and I went into the Site Actions and Navigation and thought I just change it back. Nooooo. After replication had changed it and I tried to stop it something must have happened because I got this error message now:

“An unexpected error occured while manipulating the navigational structure of this Web”

 

So I could no longer change the Navigation, and all I wanted to do was to reorder it under “Global Navigation”. Another important thing, I could change the navigation on subsites! But not on the top site in my site collection.

Googled the error and found that this had been resolved with April CU 2013. Upgraded to that, but it did NOT resolve my problem.

Went through the ULS logs and it reported:

“System.Data.SqlClient.SqlException: Cannot insert duplicate key row in object ‘dbo.NavNodes’ with unique index ‘NavNodes_AltPK’. The duplicate key value is (25a584d5-0f03-4bb5-bdea-2e57030c7817, 4e340cbd-639b-4d6e-aa19-cdb73ac35a00, 1002, -7).  The statement has been terminated.     at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)     at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)     at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)     at System.Data.SqlClient.SqlDataReader.ConsumeMetaData()     at System.Data.SqlClient.SqlDataReader.get_MetaData()     at System.Dat… 852bae04-377b-43d5-b8f5-f354a1eb54b2
10/01/2013 13:55:02.05* w3wp.exe (0x2C34)                        0x07A0 SharePoint Foundation          Database                       d0d6 High     …a.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)     at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)     at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)     at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)     at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)     at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior)     at Microsoft.SharePoint.Utilities.SqlSe… 852bae04-377b-43d5-b8f5-f354a1eb54b2
10/01/2013 13:55:02.05* w3wp.exe (0x2C34)                        0x07A0 SharePoint Foundation          Database                       d0d6 High     …ssion.ExecuteReader(SqlCommand command, CommandBehavior behavior, SqlQueryData monitoringData, Boolean retryForDeadLock)     at Microsoft.SharePoint.SPSqlClient.ExecuteQueryInternal(Boolean retryfordeadlock)     at Microsoft.SharePoint.SPSqlClient.ExecuteQuery(Boolean retryfordeadlock) 852bae04-377b-43d5-b8f5-f354a1eb54b2
10/01/2013 13:55:02.05  w3wp.exe (0x2C34)                        0x07A0 SharePoint Foundation          Database                       8z23 Unexpected Unexpected query execution failure in navigation query, HResult -2146232060. Query text (if available): “BEGIN TRAN DECLARE @abort int SET @abort = 0 DECLARE @EidBase int,@EidHome int SET @EidBase = 0 SET @EidHome = NULL IF @abort = 0 BEGIN EXEC @abort = proc_NavStructAllocateEidBlockWebId @wssp0, @wssp1, @wssp2, @EidBase OUTPUT SELECT @wssp3 = @EidBase, @wssp4 = @abort END IF @abort = 0 BEGIN EXEC @abort = proc_NavStructMoveNode ’25A584D5-0F03-4BB5-BDEA-2E57030C7817′,’4E340CBD-639B-4D6E-AA19-CDB73AC35A00′,4945,1002,-2,N’20130928 16:17:25′,@EidBase,@EidHome, @wssp5 OUTPUT SELECT @wssp6 = @abort END IF @abort = 0 BEGIN EXEC proc_NavStructLogChangesAndUpdateSiteChangedTime @wssp7, @wssp8, NULL END IF @abort <> 0 BEGIN ROLLBACK TRAN END ELSE BEGIN COMMIT TRAN END IF @abort = 0  BEGIN EXEC pro… 852bae04-377b-43d5-b8f5-f354a1eb54b2
10/01/2013 13:55:02.05* w3wp.exe (0x2C34)                        0x07A0 SharePoint Foundation          Database                       8z23 Unexpected …c_UpdateDiskUsed ’25A584D5-0F03-4BB5-BDEA-2E57030C7817′ END ” 852bae04-377b-43d5-b8f5-f354a1eb54b2
10/01/2013 13:55:02.05  w3wp.exe (0x2C34)                        0x07A0 SharePoint Foundation          General                        8kh7 High     An unexpected error occured while manipulating the navigational structure of this Web. 852bae04-377b-43d5-b8f5-f354a1eb54b2″

So values that the top navigation is using, are duplicated in a table called “dbo.NavNodes” in the content db. Or are invalid somehow.
I opened the dbo.NavNodes db and copied all lines in it, to find that duplicate key “(25a584d5-0f03-4bb5-bdea-2e57030c7817, 4e340cbd-639b-4d6e-aa19-cdb73ac35a00, 1002, -7)” and it was just a page on the site, checked in and published. Cannot really see how this page would mess all up, it has been there for quite a long time also.

I found an article that suggested to run a SQL query on the content db, to find the duplicates:

SELECTTOP(20)Count(nav.Eid)AS ‘DuplicateCount’, nav.DocId, ad.Dirname, ad.Leafname FROM NavNodesAS nav with(nolock)INNER JOIN AllDocsAS ad with(nolock)ON nav.Docid = ad.Id WHERE nav.EidParent= 1025 AND DocID IS NOT NULLGROUP BY nav.DocId, ad.DirName, ad.LeafNameORDER BY ‘DuplicateCount’ DESC

And the result was:

 
 
 

So I knew that some nodes were corrupt, and finally I found a useful article that really helped solving my problem. I ran this command a few times and carefully testing the Navigation between each, (go to Site Actions and Navigation and try to change the order in the Global Navigation). I had to run the script that deletes the nodes a couple of times (three):

Open PowerShell on the server, check the size of those objects at the top level:

$siteUrl = “http://server
$spWeb = Get-SPWeb $siteUrl
$spWeb.Navigation.QuickLaunch | ft Title
$spWeb.Navigation.TopNavigationBar | ft Title
 
Then delete the QuickLaunch Nodes using this cmd:

$siteUrl = “http://server
$spWeb = Get-SPWeb $siteUrl
    Foreach($node in ($spWeb.Navigation.QuickLaunch))
{
    write-host “The node title is “$node.Title
    $node.Delete()
}
$spWeb.Dispose()

Then delete the TopNavigationBar Nodes:

$siteUrl = “http://server
$spWeb = Get-SPWeb $siteUrl
    Foreach($node in ($spWeb.Navigation.TopNavigationBar))
{
    write-host “The node title is “$node.Title
    $node.Delete()
}
$spWeb.Dispose()

First when you run these commands you will get an error message: “Cannot complete this action” and just continue until that goes away:

 

You know when you should stop because then you don’t get a red error message any longer:

Now I went into the Site Actions > Navigation again on my site collection and now I could change the order and save.

How to replicate InfoPath forms with data connections

As I have written about before replication of InfoPath forms that are using data connections, has not been working using Metalogix Replicator http://sharepointbabe.blogspot.ae/2013/01/infopath-forms-do-not-work-with.html
But now this has been resolved by Metalogix and here are the steps needed to make this work.

1) The latest version of Replicator must be installed, that is version 6.0.7812.0

2) Make sure the AAM default zone are matching on all servers (this is most important if the local servers are using split DNS, which means that the URL headers are the same on all servers and a request to the same URL points locally instead of to the hub). Then setup any of the other zones to be individual, I have used the Intranet zone:

3) Setup the InfoPath forms to use udcx files. To do this, create a Data Connection library on your site and then convert all the data connections in the form to .udcx files and store them in the library:

4) The udcx files should be stored in a Data Connection library on a site where users have Read access, and it should also be added for replication.

 

Delete sites with “Internal server error” messages

I inherited permissions on a site the other day and boom! Got an Error message and then…. the site got the annoying “500 Internal server error” and was no longer accessible. Great. No immediate cause in the log files, though scanned them up and down. Enabled custom errors in web.config and got this error:
“The DataSourceID of ‘TopNavigationMenuV4’ must be of the ID of a control of type IHierarchicalDataSource. A control with ID ‘topSiteMap’ could not be found.”

Wow. What the hell is that. Googled it and found a SQL query you could run in your db to fix this. But that only ended up in “0 rows affected” so no luck. I guess there were more errors than just this…

 

Tried all possible ways to access the sites like adding _layouts/settings.aspx, adding ?contents=1 after welcome.aspx, opened Manage content and structure but the site was not listed there, opened Site Settings and Site hierarchy and clicked on Manage (strangely enough the link to the site and subsites was still in there) but all I got was the “Internal server error” message.
I googled to death to find a solution but there seemed to be none that worked for me. But found this article on MS that this is a known issue: http://support.microsoft.com/kb/937038. But that is for MOSS and we are on SP2010 so did not dare apply that.

Seemed like the only solution was to restore the site.
But I could not restore it back to its original place since the sites were still there… even if I tried the force command I could not overwrite the sites (using the Import-SPWeb and -force). Error in Powershell was cannot find an spweb object with ID or URL…
Could not delete the site through Powershell command delete either (Remove-SPWeb). Same error in powershell as above.

Finally found a command that worked though and that is run through STSADM in Powershell:

1) First enum all sites stsadm -o enumallwebs -databasename WSS_YourDBname
2) Then you need to find out what GUID the db’s has (I usually export them to a txt file for easy copy)
Get-SPWebApplication “http://spserver/” | Get-SPSite -Limit All | Get-SPWeb -Limit All | Select Title, ID, URL | out-file d:webs.txt | format-table -auto
3) In Powershell enter this command
stsadm -o deleteweb -force -webid “GUID” -databaseserver yourdbserverinstancename -databasename WSS_YourDBname

This will delete the sites.
Some of these deletions can take a looong time. But just leave it running, do not interrupt it.

 

Error in the personal information on MySite

If you see this error on the MySite and personal information page:

“There was a problem retrieving data for this field. Updating values in this field is disabled temporarily. You can still update values in other fields.”

Then something is wrong with the Managed Metadata Service. Clicked on the service app for Managed Metadata service and got the following error:

So check the following things to fix this:

* In CA, Services on server, restart the Managed metadata service

* In CA, verify that the Service Application is associated to the MySites web app
* Is the Application pool started

* In EventViewer, look for errors. I had this error (8088, The managed metadata service is inaccessible):

* So that error in Event Viewer made me check the Site Collection Administrators on the Content Type hub site, and the service account was removed (for some strange reason…) so I added the it again, and the Managemed Metadata and MySite started working immediately:

Script for SharePoint installation

This weeks task was to setup a SP2010 medium server farm. It took half a day, and using this powershell script to install the index server was AWESOME! You must edit the files before you run them, to add your own db names, servers etc, but once that is done it’s a really fast setup! And, it also gives your default SP databases nice names, not GUIDs! The only databases it doesnt setup names for, are Application Registry, BDC and Search dbs:

Link to script here, at Codeplex.

User profile synchronization error

The crawl log in Search Administration returned the following error:

sps3://xxx could not be crawled

What you must do is to set permissions to the search account that you use for crawling the User Profiles.

Select User Profile Services (do not click the link, but highlight the application)

Up in the ribbon, click a button called “Administrators”

Enter the account that you use for search

Add the permission “Retrieve people data for search crawlers”

My first SP2010 installation, critical issues

This week I have installed my first SharePoint 2010 server and it has been great fun and very interesting! It is a test environment so it’s a small server farm setup. After having a connection issue with the SQL server (everything is closed and denied) it was a fast and easy installation. Well that was the smallest part…

Fired up Central Administration, and went through it step by step. Trying to memorize where to find everything =) When you have worked for years in MOSS then it is a bit messy… When most settings were ready, the red ribbon turned up and warned about the farm having “Critical issues”. Clicked on the messages and there were some errors:

1) The server farm account should not be used for other services
Ah yes, of course, an old classic. Open “Manage service accounts” and change the account to the one you use for your services in general. Not the farm admin account or an account who is a member of the local admin group.

2) Accounts used by application pools or service identities are in the local machine Administrators group. ยจ
Click on “Manage service accounts” and change all services that uses your farm account to a specific service account instead. That account should be a least privilege account. Like before..

3) The unattended service account application id is not specified or has an invalid value.
This means that you must generate a new key and configure the Secure Store Service.

4) Missing server side dependencies
Did not really understand WHAT was wrong… so what do you do? Google of course! And yes, I was not alone… Found this guy’s blog with a solution that I found was hilarious! I thought he had forgotten to write down a step in this solution, but no – follow these steps and the error message is gone! =)
Click General Application Settings
Under Search, click Farm-Wide Search Administration
Under Search Service Application click Search Service Application
Run iisreset -noforce (don’t forget to run cmd as Administrator or else you get Access denied)
Thanks to http://sharepointinsight.wordpress.com/

5) Verify that the Activity Feed Timer Job is enabled.
Well, just DO IT! Inside the timer job definitions, enable it.

6) Built in accounts are used as application pools or service identities
Again, change to correct account!

7) Validate the MySite host and individual MySites are on a dedicated web application and separate URL domain.
After a web application for MySite was setup, and some managed paths entered, this message disappeared.