Posts

Showing posts from March, 2011

Enabling a Button on the Ribbon Based on Selection

Image
Enabling a Button on the Ribbon Based on Selection A lot of people have asked me how to create a button which enables if and only if a single item is selected. This isn’t something we have out of the box, but the code to get this functionality is pretty simple. I’m going to assume that you’re generally familiar with SharePoint, CustomActions, and customizing the Ribbon – if that’s not the case, you’d probably be better off researching those things before delving into this. Basically, the enabling behavior all boils down to the following few lines of code: EnabledScript = " javascript:function singleEnable() {   var items =     SP.ListOperation.Selection.getSelectedItems();   var ci = CountDictionary(items);   return (ci == 1); } singleEnable(); " What this does is query to get the dictionary of selected items, and if the size of the dictionary is 1 it returns true (enable), otherwise it will return false (disable). Technically,

How To Hide Ribbon From Users Without Edit Page Privilege

 A way to remove or hide the ribbon area from user with lease privilege, and here is how: 1)       Open your SharePoint master page 2)       Locate this line: < div id ="s4-ribbonrow" class ="s4-pr s4-ribbonrowhidetitle"> 3)       Change it to: < div id ="s4-ribbonrow" class ="s4-pr s4-ribbonrowhidetitle" style =" display :none" > 4)       Now find the end of the “ s4-ribbonrow ” tag and add following block right after it: < Sharepoint : SPSecurityTrimmedControl ID ="SPSecurityTrimmedControl2" runat ="server" PermissionsString ="AddAndCustomizePages">     < script type ="text/javascript">         document.getElementById( "s4-ribbonrow" ).style.display = "block" ;     </ script > </ Sharepoint : SPSecurityTrimmedControl > 5)       Save the new master page and publish it. Learn more about SPSecurityTrimmedControl

How to Remove Corrupted SharePoint Sites – Preparing for SharePoint 2010 Upgrade

  SP2 had a number of enhancements designed around making it easier to upgrade to SharePoint 2010.  One such new feature that wasn’t popularized is your ability to find and remove corrupted, broken sites known as orphans. As I’ve mentioned in the past, with SharePoint being split across multiple databases, it is quite possible that a site could be in either the content database OR the config database. With service pack 2 there’s a new way to find orphaned sites.  In addition to running STSADM –o PreUpgradeCheck , one of my favorite tools along with TEST-SPContentDatabase with SharePoint 2010 you can identify these messed up corrupted sites. You’ll run enumallwebs (STSADM reference on TechNet) to identify the orphaned sites, and use deletesite (STSADM reference on TechNet) to remove them.  Note this command is available in SP2, and was enhanced in the post SP2 October Cumulative update.  You really should consider that October update as the most significant release with