Deleting all nodes from QuickLaunch

This is my code to delete the QuickLaunch Navigation Nodes.
I am using the SharePoint 2013.
public void 2013NodeOrders(string siteUrl, string quickLaunch)
SPSecurity.RunWithElevatedPrivileges(() =>
using (var localWeb = new SPSite(siteUrl).OpenWeb())
try
var ql = localWeb.Navigation.QuickLaunch;
int count = 0;
while (count++ < 10)
try
CleanUpAutoCreatedNodes(ql, nodeNames.ToArray());
break;
catch (Exception ex)
localWeb.Update();
catch (Exception ex)
Console.WriteLine("Error Occoured ", ex);
throw ex;
private static void CleanUpAutoCreatedNodes(SPNavigationNodeCollection ql, string[] nodenames)
foreach (SPNavigationNode globalNode in ql)
if (Array.IndexOf(nodenames, globalNode.Title) == -1)
if (globalNode.Children.Count > 0)
foreach (SPNavigationNode childNode in globalNode.Children)
childNode.Delete();
if (!globalNode.Title.Equals("Site Contents"))
globalNode.Delete();
I got the following COM Exception Error from the lines foreach
(SPNavigationNode globalNode in ql)and foreach
(SPNavigationNode childNode in globalNode.Children)
Error Message :
Cannot complete this action.
        Please try again.<nativehr>0x80004005</nativehr><nativestack></nativestack>
    Stacktrace Error
       at Microsoft.SharePoint.Library.SPRequestInternalClass.GetNavigationNodeChild(String bstrUrl, Int32 lParentId, Int32 lIndex, Int32& lNodeId, String& pbstrNodeUrl, String& pbstrName, String& pbstrNameResource,
String& pbstrDateModified, Int32& pbIsVisible, Int32& pbIsExternal, Int32& plNumChildren, Guid& pgScopeId, Int32& plParentObjectType)
       at Microsoft.SharePoint.Library.SPRequest.GetNavigationNodeChild(String bstrUrl, Int32 lParentId, Int32 lIndex, Int32& lNodeId, String& pbstrNodeUrl, String& pbstrName, String& pbstrNameResource, String&
pbstrDateModified, Int32& pbIsVisible, Int32& pbIsExternal, Int32& plNumChildren, Guid& pgScopeId, Int32& plParentObjectType)

Hi Benodh,
Have your tried to use the below sampe to iterate the collection:
for(int i = globalNode.Children.Count-1; i>-1; i--){
   globalNode.Children[i].Delete();
Thanks,
Qiao Wei
TechNet Community Support

Similar Messages

  • How to delete a node from a node network

    How do I delete a node from a node network?
    <P>
    <OL>
    <LI>Follow the instructions on page 30 of the Calendar Server (CS) 3.x Admin Guide,
    and page 62 of the CS 4.0 Admin Guide "Deleting (excluding) a Node from the
    Network".
    <LI>Shut down the Directory Server.
    <LI>Backup the LDAP directory to an LDIF file.
    <LI>Edit this LDIF file and delete references to the
    6 calendar reserved users for the node to be deleted.
    <LI>Restore the LDAP directory with this changed LDIF file.
    <LI>Run unidbfix -export -n all
    <LI>Edit the resulting remotenodes.ini
    files and delete all
    references to the node to be deleted.
    <LI>Run unidbfix -import -n all
    <LI>Start the Directory Server.
    <LI>Start the Calendar Server.
    <P>
    Note: This next step is for Calendar Server 3.x * ONLY *
    <P>
    <LI>Run unireqdump -delete
    to delete all requests to the node
    to be deleted.
    </OL>

    Divya wrote:
    Hi,
    I'm using forms6i.
    I want to delete unselected nodes from a tree
    How can it be done??
    ThanksIf you mean empty branches as unselected nodes,
    set Allow Empty Branches property to 'No' in the Trees property.

  • Delete all calendars from an iCloud account

    Hi  Support Communities,
    did anyone find a way to delete all calendars from an iCloud account? It seems that iCloud wants to keep at least one calendar. We use several accounts and one is only used to look at shared calendars from other accounts. So there is no need for its own empty calendar. On iOS I just hid this calendar, but on OS X it is always visible. I unchecked it, but it would be nice if I could just delete it. If I do so on an iOS device it is gone, but reappears later. Trying to delete it on a Mac results in an error that it can’t be deleted, same goes for the web interface at icloud.com. It’s just a cosmetic issue, but I would prefer it to be gone altogether. Any ideas?
    Thanks
    Björn

    I had hoped I was wrong, you never know. Well, thanks anyway!
    Björn

  • Delete All Calendars from iPad?

    Simple question; hopefully a simple solution.
    I want to delete all calendars from my iPad2, so that I can then copy the calendars from my Mac onto it?
    I want all of the data deleted from my iPad, and don't want it to show back up again.
    Like I said, it should have a simple solution.
    Thanks!
    Jon
    iPad 2, iOS 4.3.3 14 GB
    MacBook Pro, 2.26 GHz Intel Core 2 Duo, 4 GB 1067 MHz DDR3, Mac OS X 10.6.8

    Does this help you:
    http://www.ehow.com/how_7427878_delete-calendar-ipad.html
    Repeat the same procedure for all calendars.
    If the calendars came in via an Exchange account, you can remove the calendar syncing by editing the exchange account (settings -> mail, contacts and calendar -> accounts) and switch "calendar" in this (http://blog.fosketts.net/wp-content/uploads/2010/04/Exchange-Account-MCC.png) dialog to off.

  • Delete all entries from the following tables - Follow-up Activities (oracle)

    Hello,
    I performed a homogeneous system copy of our development BW system with the database (oracle 11.2.0.3) from the BW production system!
    I already start the oracle database and the SAP system in the target system/server (development BW system) and I´m doing some follow-up activities. One of this activities is (at the system copy guide 6.2.3.2 Activities at Database Level) is to delete all entries from the following tables:
    DBSTATHORA, DBSTAIHORA, DBSTATIORA, DBSTATTORA
    I tried to delete them using SQL Plus:
    sqlplus /nolog
    SQL> connect /as sysdba
    SQL> delete from DBSTATTORA;
    delete from DBSTATTORA
    ERROR at line 1:
    ORA-00942: table or view does not exist
    ... and it show me that error message.
    This is strange because when I go to transaction SE14 and check the DBSTATTORA I see that table exist and contain a lot of entries!
    Why this is happened in SQL Plus!? I´m running the correct SQL statement for doing this type of task or not?
    How can I delete the entries of that tables? Can I do that using the transaction SE14?
    Can you help me please?
    Thank you,
    samid raif

    Hello
    sqlplus /nolog
    SQL> connect /as sysdba
    SQL> delete from DBSTATTORA;
    delete from DBSTATTORA
    ERROR at line 1:
    ORA-00942: table or view does not exist
    It doesn't surprise me as you are not mentioning the schema name here. Instead it should be
    delete from SAPSR3.DBSTATTORA;
    Assuming the schema owner is SAPSR3. if the owner is different then replace that with the correct one.
    Regards
    RB

  • How can i Delete all foto from my iphone and after some time get them one more time on it but not as a new album :)?

    How can i Delete all foto from my iphone and after some time get them one more time on it but not as a new album, i want them in the camera roll ?

    How can I delete EVERY THING off my Mac and have it like new?
    Boot from the software install DVD and do an "erase and install" when prompted.

  • How to Delete the node from cluster when the machine crashed?

    In an three nodes Rac of 11g r2,How to delete the node from cluster when the machine crashed?
    There is now way to repair the machine and have to add a new one.
    What is step to follow up?

    hi
    IF YOU WANT TO DELETE RAC1 NODE
    check $./olsnodes
    1) delete the instance using dbca from any active nodes
    crs_stat -t
    srvctl stop asm -n rac1
    2) delete listener
    3) delete oracle_home from oracle user
    $ORACLE_HOME/bin/runInstaller -updatenodelist ORACLE_HOME=<db_home> "CLUSTER_NODES={RAC1}
    4)delete asm home
    $ORACLE_HOME/bin/runInstaller -updatenodelist ORACLE_HOME=<asm_home> "CLUSTER_NODES={RAC1}
    5) update cluster node
    $ORACLE_HOME/bin/runInstaller -updatenodelist ORACLE_HOME=<db_home> "CLUSTER_NODES={active nodes like rac2,rac3}
    6) update ASm home
    $ORACLE_HOME/bin/runInstaller -updatenodelist ORACLE_HOME=<asm_home> "CLUSTER_NODES={active nodes like rac2,rac3}
    cd $ORA_CRS_HOME
    cd crs/opmn/conf
    check for
    $cat ons.config
    remoteport=6200
    cd crs_home/bin
    $./racgons remove_config rac1:6200
    $ go to crs home
    and $ORA_CRS_HOME/crs/install/rootdelete.sh
    $ORA_CRS_HOME/crs/install/rootdeletenode.sh
    check for ./olsnodes

  • Why is there no way to delete all emails from my iphone?

    Why is there no way to delete all emails from my iphone? IOS 7.1. Every other phone in the market allows you to 'select all' then delete.
    This trick of selecting one, then holding move, then unchecking (and subsequently moving all the emails to trash) doesn't work. I've read these suggestions and while it appears to work the emails just show up again once you leave and return to the inbox. Perhaps it worked on an older version of IOS.
    It blows my mind this is not a standard function. I get a few hundred emails at work every day, and most of the time I just want to delete all of them from the phone as I've read them already. Currently it seems i can only click edit and then have to check each email individually to be able to delete them at the same time; this is the definition of tedious. I would think there are millions of other iphone users who get their company email on their phones that must experience the same thing. It seems now i either spend 20 minutes a day deleting emails, or just let thousands of emails accumulate on the phone (taking up space and also making it hard to just review the most recent emails which is all I want to be able to do when checking email on my phone).
    I am hoping I am just missing some simple solution here that everyone else uses. Please help!!
    Mark

    Only Apple could answer as to why there is no "select all/"delete all" function in the iOS mail app. Users have been bemoaning this lack of functionality for years now. Like everyone else, you can submit feedback to. Apple here.
    Apple - iPhone - Feedback
    While I understand the whole idea of being able to use the phone on the run, if you have an IMAP email account, and if you have access to a computer at work during the day, use your "select all" function on the server and delete all of the unwanted email there and it will be removed from the phone as well.
    That doesn't solve the problem on the phone, but it gets rid of the email which is your ultimate goal anyway.

  • How to delete all events from iCal?

    Is it possible to select and delete all events from iCal? Or is it simpler to delete the calendar itself? Thanks!

    Sorted now!
    To clarify for people like me: type "." in the search bar
    Then click on the first item in the results pane
    Go to the other end of the list, hold down shift, and click the LAST item
    They should all be highlighted now
    Then use Edit/Delete
    NB it may take a couple of mins (or ten!) for the items to disappear from your view, particularly if syncing with MobileMe.

  • How do i delete all messages from my email?

    I had a server problem over the weekend and all of my email messages that i got from day #1 are reloading as new, unread mail. How can i delete them all(thousands). I'm using outlook and have not been able to sync my Inbox. Contacts and all else is fine.???

    Check your account settings with Outlook for removing or deleting messages from the server when downloaded by Outlook.
    The iPhone's email client includes the same settings, as do all email clients for a POP account.
    I would handle this with Outlook. Delete and recreate the account with Outlook, and before checking the account for new message with Outlook, select remove or deleted messages from the server when downloaded for the account preferences with Outlook.
    All messages available on the server will be downloaded again by Outlook, and removed from the server when doing so. You can mass delete all messages from Outlook.
    When deleting and recreating the account with the iPhone's Mail client, none of these messages will be downloaded by the iPhone's Mail client after being removed from the server when downloaded by Outlook.
    Or since you likely have webmail access for this account using a browser, you can mass delete all messages available on the server via webmail access. After deleting the messages from the server, delete and recreate the account with the iPhone's Mail client.
    An IMAP account is much easier in this regard, which is designed to be accessed with multiple email clients on different computers or devices.
    A POP account is designed to be accessed with a single email client on one computer or device.

  • Deleting all elements from array and array to spreadsheet string

    Hello,
    I would like to write a new data file for each "recording" session without closing the VI.  My problem is that the last "recording" session's data is at the top of every successive session's text file.  I do not want this.  I've tried to delete all rows from the array after my array to spreadsheet string function, but I think the problem is somewhere with the shift register and how the array is built.  I'm not too familiar with LabView and this aspect of my interface is driving me crazy.  Attached is my code and two successive data files.  I have not been able to find a solution on these or the LAVA forums.  Any help would be appreciated.
    Also, I know there is an easier way to write this kind of streaming data, but I need to do it this way for other devices and synchronization purposes.
    Attachments:
    testsecond.txt ‏90 KB
    test41.vi ‏80 KB
    testfirst.txt ‏78 KB

    A few more comments to your code:
    Your loop does not have a wait, meaning it spins the empty case millions if times per second, consuming all CPU while not doing anything. Add an indicator to [i] to see.
    To clear a 2D array in one case frame, just don't wire the output tunnel and set it to "use default if unwired". You'll get an empty array. No fancy tools needed.
    I probably would use an event structure and also protect the data if the save dialog is canceled.
    Here's a simple draft that probably requires a bit more work but should show some of the ideas.
    You should also
    add some protection that the VI cannot consume all available memory if it runs forever.
    Create a seperate case to save the data later if the file dialog is cancelled the first time.
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    test41MOD.vi ‏107 KB

  • I previously had PS CS5 Trial installed but removed it using both Control Panel Programs and deleting all files from the CS5 directory on Program Files.  I then installed a purchased product from Adobe disc using the serial number on the case.  But when I

    I previously had PS CS5 Trial installed but removed it using both Control Panel Programs and deleting all files from the CS5 directory on Program Files.  I then installed a purchased product from Adobe disc using the serial number on the case.  But when I try to launch it, I get a screen headed Photoshop CS5 Extended Trial.  It asks for the serial number and says that my trial has expired.  It rejects the serial number from the Adobe case saying "This Serial Number is not valid for this product".  It thinks that I still have the expired Trial Version installed.  How do I convince it (the program) that the Trial Version is long gone and the currently installed product was installed with a valid and accepted serial number????

    Let me know how it goes. Go into your Adobe account and register your serial number asap.
    https://www.adobe.com/account/my-products-services.html
    That way, should you lose it or you need support, it is on record that it's yours and you can fetch your s/n it from anywhere.
    There are too may sad stories here, where people forgot and the box is buried or lost.
    Gene

  • I mistakenly deleted all browsers from my laptop in an attempt to start clean with the newest version of Firefox. I still have Firefox on my desktop. How can I copy it to my laptop?

    I mistakenly deleted all browsers from my laptop in an attempt to start clean with the newest version of Firefox. I still have Firefox on my desktop. How can I copy it to my laptop?

    Re-installing the Firefox browser is fairly easy. For most users the important part is the information held in the [[profiles|profile]] including bookmarks and passwords.
    If you remove personal settings it is almost impossible to get them back. You can however [[what is firefox sync?|sync]] between computers, and that effectively clones your bookmarks etc.
    If you have not already removed setting do not do so now, some of that info may be recoverable.

  • Already deleted all files from my MINIMAC and still appears to have only 200 gb free. How do I format the macmini?

    Already deleted all files from my MINIMAC and still appears to have only 200 gb free. How do I format the macmini?

    If you deleted from within the OS, did you empty the Trash?

  • I was organizing my photos into albums. then deleting them from my Camera roll. Then I went into MY Photo Stream and started deleting the pics I had moved to albums;Come to find out I deleted all pic from everywhere!!  Would the iCloud still have them sav

    I was organizing my photos into albums. then deleting them from my Camera roll. Then I went into MY Photo Stream and started deleting the pics I had moved to albums;Come to find out I deleted all pic from everywhere!!  Would the iCloud still have them saved

    First of all, you should always save you photos on computer like any other digital camera.
    Backup on iCloud or iTunes only backup your Camera Roll. The other photos should be already on the computer.
    Note: Photos are not saved in iTunes, it's only a conduit between your iPhone and your photo managing software on computer.
    What computer do you have?

Maybe you are looking for

  • Itunes encountered problem and needs to be closed

    i keep trying to open itunes, but before it even opens, it says theres a problem and needs to be closed. is there anyway i can fix this?

  • MS Word report not visible in executable

    We are using LV 7.1 FDS (with app builder) on Win2000 prof. We have Report Generation Toolkit and Database Connectivity Toolkit installed (among others). Our VI publishes reports in MS Word. When the user clicks the "report" button, the VI generates

  • Display problems with allowing web pages to use their own fonts, both on and off.

    I refer to the "Allow pages to choose their own fonts, instead of my selections above" option in the Content > Advanced tab of the Options menu. When I have this option unchecked, allowing my font choice to override the default non-image generated te

  • Solaris 10 problem

    I'm using a server with AMD Opteron 252 CPU and chipsets Nvidia CK8-04, Geforce2 MMX 400. Solaris 10 installation goes smoothly. Except when installation is done and machine is rebooted, this error message appears before loading the Common Environmen

  • CER Use port description as port location

    Hello all, I am trying to confirm if this "feature" is as useless as I have found it to be. From my testing and what little documentation I can find when checking the "Use port description as port location" check box on the LAN switch details screen