Beware of deleting Global Navigation nodes in SPWeb.Navigation.GlobalNodes
For a standard team site (STS#0) the GlobalNodes SPNavigationNodesCollection will contain three SPNavigationNode objects.
Home, Quick Launch and SharePoint Top Navigation Bar, these each have Ids of 1000, 1002 and 1025 respectively.
The problem occurs if you delete Quick Launch or SharePoint Top Navigation nodes. Even if you then add them back in a new ID is generated and SPWeb.Navigation.TopNavigationBar looks for child nodes under a node with an Id of 1002 (This is hard coded).
Through the API this means that SPWeb.Navigation.TopNavigationBar will always be null and through the SharePoint UI an error will be returned to the user (“Value does not exist in that range”).
The only ways I have found to fix this is to delete and re-create the site or (Microsoft please close your ears) get the site id and web id and query the NavNodes table in the content database the site collection sits in and add the following records
SiteId |
WebId |
Eid |
EidParent |
NumChildren |
RankChild |
ElementType |
Url |
DocId |
Name |
DateLastModified |
NodeMetaInfo |
NonNavPage |
NavSequence |
ChildOfSequence |
C803FD13-27FA-475F-909C-2CE5B2048E1B |
A31E8093-1505-4E1C-B7CC-04D6B952A33F |
1000 |
0 |
0 |
0 |
0 |
NULL |
A31414EE-953B-44CC-A37E-4D5D643B002A |
Home |
2008-04-04 11:28:21.000 |
NULL |
False |
False |
False |
C803FD13-27FA-475F-909C-2CE5B2048E1B |
A31E8093-1505-4E1C-B7CC-04D6B952A33F |
1002 |
0 |
0 |
2 |
1 |
|
NULL |
SharePoint Top Navigation |
2008-04-04 11:28:21.000 |
NULL |
False |
True |
False |
C803FD13-27FA-475F-909C-2CE5B2048E1B |
A31E8093-1505-4E1C-B7CC-04D6B952A33F |
1025 |
0 |
0 |
1 |
1 |
|
NULL |
Quick Launch |
2008-04-04 11:28:21.000 |
NULL |
True |
True |
False |
Leave a Reply Cancel reply
Pages
Follow me on Twitter
Error: Twitter did not respond. Please wait a few minutes and refresh this page.
I think top nav bar is 1002 and quick launch is 1025.
Hi, that is correct. The formatting of my blog theme seems to have cut half the table off that has the name column in it.
Is it by design that if you create a search site, you cannot use the top navigation either? Selecting “Display the same navigation items as the parent site” does not seem to work for these type of sites.
It worked for me!!! Thanks man! I just had to add one entry though:
INSERT INTO [PI_Content_BMA02].[dbo].[NavNodes]
( SiteId,
WebId,
Eid,
EidParent,
NumChildren,
RankChild,
ElementType,
Url,
DocId,
Name,
NameResource,
DateLastModified,
NodeMetainfo,
NonNavPage,
NavSequence,
ChildOfSequence
)
VALUES ( ’64DD26C0-77E6-4DB1-95A0-151B86D9F33A’,
‘531127B5-C5BC-4C9A-958F-1B0E30D7FC95’,
1002,
0 ,–NumChildren
0,
1,
1,”,
NULL, –DocId
‘PKC SharePoint Top Navbar’ ,
‘PKC SharePoint Top Navbar’,
‘2011-06-10 02:18:01.000’,
NULL ,
0,
1,
0
)
Here are the scripts that helped me to resolve the issue
INSERT INTO [NavNodes]
([SiteId], [WebId], [Eid], [EidParent], [NumChildren], [RankChild],[ElementType], [Url],
[DocId], [Name], [DateLastModified], [NodeMetainfo], [NonNavPage], [NavSequence], [ChildOfSequence])
SELECT DISTINCT SiteId, WebId ,1002 ,0 ,0 ,1 ,1 ,”, NULL, ‘SharePoint Top Navbar’,getdate() ,NULL ,0 ,1 ,0
FROM NavNodes WHERE WebId NOT IN (SELECT WebId FROM NavNodes WHERE Eid = 1002)
INSERT INTO [NavNodes]
([SiteId], [WebId], [Eid], [EidParent], [NumChildren], [RankChild],[ElementType], [Url],
[DocId], [Name], [DateLastModified], [NodeMetainfo], [NonNavPage], [NavSequence], [ChildOfSequence])
SELECT DISTINCT SiteId, WebId ,1025 ,0 ,0 ,0 ,1 ,”, Null, ‘Quick launch’,getdate() ,NULL ,1 ,1 ,0
FROM NavNodes WHERE WebId NOT IN (SELECT WebId FROM NavNodes WHERE Eid = 1025)
Excellent, cheers for that.
This is pretty close to what you need some typos on previous postings.
Leo, the NavNodes table does not contain a column ‘NameResource’.
Also, the EidParent, NumChildren and RankChild can’t be 0,1,1 for SharePoint Top Navbar entry – 1002.
Syntax is :
–For Top Nav bar.
INSERT INTO [NavNodes]
([SiteId], [WebId], [Eid], [EidParent], [NumChildren], [RankChild],[ElementType], [Url],
[DocId], [Name], [DateLastModified], [NodeMetainfo], [NonNavPage], [NavSequence], [ChildOfSequence])
SELECT DISTINCT SiteId, WebId ,1002 ,0 ,1 ,2 ,1 ,”, NULL, ‘SharePoint Top Navbar’,getdate() ,NULL ,0 ,1 ,0
FROM NavNodes WHERE WebId NOT IN (SELECT WebId FROM NavNodes WHERE Eid = 1002)
If you apply the above actions, your Sharepoint Server will become unsupported.
http://support.microsoft.com/kb/841057
The only call for support that you can raise is to bring your server back into a supported state.
Yeah cheers for that. Any useful suggestions on how to solve the problem then without doing this?
I,m not implying that this should be done in a production environment or anything hence my “tongue in cheek” comment; “Microsoft please close your ears”.
Really I shouldn’t be able to delete this node if the ID is hard-coded into Microsoft’s code.
Maybe Microsoft should change the support agreement to
Adding, changing, or deleting any data in any table of any of the databases for the products that are listed in the “Applies to” section, unless we balls up the code so your environment crashes with a random error messages and you have to spend a good part of a day using .NET Reflector to find out why and then tell Microsoft Technical Support what is wrong with their product.
You know, just saying and that.