Friday, September 27, 2013

How to Hide the Edit Tab in a Ribbon

In SharePoint 2010, add the following code to a CEWP.



<script type="text/javascript">// <![CDATA[
function ResetRibbon() {
try {
var ribbon = SP.Ribbon.PageManager.get_instance().get_ribbon();
SelectRibbonTab("Ribbon.Read", true);
ribbon.removeChild('Ribbon.ListForm.Display');
ribbon.removeChild('Ribbon.ListForm.Edit');
} catch (e)
{ }
}
SP.SOD.executeOrDelayUntilScriptLoaded(function () {
try
{
var pm = SP.Ribbon.PageManager.get_instance();
pm.add_ribbonInited(function () {
ResetRibbon();
});
var ribbon = null;
try {
ribbon = pm.get_ribbon();
}
catch (e) { }
if (!ribbon) {
if (typeof (_ribbonStartInit) == "function")
_ribbonStartInit(_ribbon.initialTabId, false, null);
}
else {
ResetRibbon();
}
},
"sp.ribbon.js");
}catch(e)
{}
// ]]></script>
<script type="text/javascript">
function ResetRibbon() {
try {
var ribbon = SP.Ribbon.PageManager.get_instance().get_ribbon();
SelectRibbonTab("Ribbon.Read", true);
ribbon.removeChild("Ribbon.ListForm.Display");
ribbon.removeChild("Ribbon.ListForm.Edit");
} catch (e)
{ }
}
SP.SOD.executeOrDelayUntilScriptLoaded(function () {
try {
var pm = SP.Ribbon.PageManager.get_instance();
pm.add_ribbonInited(function () {
ResetRibbon();
});
var ribbon = null;
try {
ribbon = pm.get_ribbon();
}
catch (e) { }
if (!ribbon) {
if (typeof (_ribbonStartInit) == "function")
_ribbonStartInit(_ribbon.initialTabId, false, null);
}
else {
ResetRibbon();
}
} catch (e)
{ }
}, "sp.ribbon.js");
</script>

and the tab will disappear :) 

Source: http://sharepoint247.wordpress.com/2013/05/24/javascript-to-hide-or-select-specific-tabs-in-sharepoint-ribbon/




Remove Content Approval Message from Forms.


Whenever a SharePoint list requires content approval for submitted items, you will find the following message on  your new item forms:

"'Items on this list require content approval. Your submission will not appear in public views until approved by someone with proper rights.'"

I find this message very confusing to my users so I often remove it. 

To remove the message,

  1. Go to 'List settings' and then 'Advanced settings'
  2. Scroll down to 'Dialogs' 
  3. Select 'No' under 'Launch forms in a dialog?' then select 'OK'
  4. Go back to your list and select 'Add new item'. Your new item form will open as a page.
  5. Go to 'Site Actions ' and select 'Edit Page'
  6. Add a CEWP (Content Editor Web Part)
  7. Edit the web part's html source code 
  8. Enter the following CSS: 

<style>
.ms-informationbar{visibility:hidden;}</style>

    10. Click save 

The message will be removed from the form. 

If you want your forms to open as dialogues again, simply follow steps 1-3. However, in step 3 select 'Yes' instead.