1

Good day! Faced this challenge: to create a button on the Ribbon by using SharePoint Disigner 2010 "Custom Action" - View Ribbon, hung on the button workflow. Now I need to hide a button on the Ribbon depending on the status of the list of "new" or "Completed." How to hide a button is all I have found how to make (made ​​using the Content Editor, has registered id button and set Display = none), but as the conditions of the rights of the user to hide or not found. Hide button without the need Visual Studio

2 Answers 2

1

Custom actions are normally hidden as a function of SharePoint permissions; refer to the documentation on the Rights attribute of the CustomAction element. A custom action can also be conditionally disabled via the EnabledScript attribute of the CommandUIHandler element. The piece of JavaScript attached to this attribute is executed in order to determine if the custom command should be enabled or disabled.

You mentioned that you're using SharePoint Designer and that you wish to avoid using Visual Studio. I'm not aware of a supported method to expose the attributes mentioned above within SharePoint Designer. I did, however, come across this post in which the author discusses a method of setting the EnabledScript property of a custom action (created via SharePoint Designer) programmatically within $(document).ready(){...}. This would allow you to write a custom JavaScript function to determine the status of the selected/current item and enable or disable your custom action accordingly.

0

You can use JQuery in a CEWP to hide the ribbon. It will hide the entire thing though:

<script type="text/javascript" src="/_layouts/js/jquery-1.11.0.js"></script>
<script type="text/javascript" src="/_layouts/js/jquery.SPServices-2014.01.js"></script>


<script type="text/javascript">

$(document).ready(function(){
$().SPServices({
operation: "GetListItems",
async: false,
listName: "MyList",
CAMLViewFields: "<ViewFields><FieldRef Name='StatusField' /></ViewFields>",
completefunc: function (xData, Status) {

//alert(xData.responseXML.xml);

$(xData.responseXML).SPFilterNode("z:row").each(function() {

     var xitem = $(this);
     var status = xitem.attr("ows_StatusField"); 

   if (status == "New" || status =="Complete"){

$("#s4-ribbonrow").hide();

var newHeight = $(document).height();

if ($.browser.msie) {newHeight = newHeight - 3; }

  $("#s4-workspace").height(newHeight);

}

});
}
});    
});

</script>
3
  • thanks I'll try. And the code inserted in the content editor?
    – Ann
    Commented Oct 14, 2014 at 3:58
  • Hiding the entire ribbon to hide a single custom action is a little much, isn't it? But, if it meets your requirements, then by all means. Commented Oct 14, 2014 at 4:15
  • Yes be sure to add the SPServices Libraries, and yes, this is over kill, but it will remove the ribbon.
    – lazoDev
    Commented Oct 14, 2014 at 13:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.