none
User Custom Action in Ribbon is always disabled in O365. How do I enable it, or could something be causing it to remain disabled? RRS feed

  • Question

  • Hi,

    I've recently been building a SharePoint-Hosted app to manage User Custom Actions in O365.

    I am using the api referenced here:

    http://msdn.microsoft.com/en-us/library/office/jj245771(v=office.15).aspx

    I can successfully make the POST requests to create a custom action with the Location as "CommandUI.Ribbon" and sublocation as "Ribbon.Documents.New.Controls._children", and all the other necessary settings. The action shows up in the ribbon but it is disabled.

    However, if I create the custom action declaratively by adding an item to the app project and apply the same settings, the action is visible and enabled.

    Notice, the action on the left was created programmatically by using Javascript, the action on the right was added on app installation from using VS2013 and adding it to the project. 

    I've read multiple other resources about people who are intentionally putting code into the EnabledScript attribute of the CommandUIHandler element which was the cause of theirs being disabled incorrectly, but this isn't relevent in my case. I am not setting that attribute on my CommandUIHandler element.  From my understanding, all buttons are enabled by default and  that attribute should only be needed if you need to conditionally disable the button. 

    see: http://stackoverflow.com/questions/18700035/custom-button-on-custom-tab-is-always-disabled-ribbon-bar

    I can even query for all the user custom actions in the site and I get back the two actions (the one created via javascript, and the one created via Elements.xml) and they have all the same basic properties.  Obviously, Id and Name GUIDs are different but the rest is conceptually the same.

    I have also ensured that the string in the Command attribute of the button matches the string in the Command attribute of the CommandUIHandler. I tried creating the action in different sections of the ribbon but it is always disabled, and I have tried setting the EnabledScript attribute to return true.

    At this point I'm starting to think it's a problem with O365 or the REST API I'm using but I wanted to ask for help here to see if anyone knows a solution / work around.

    Here are some questions that I have that might help:

    Is my assumption that all buttons are enabled by default incorrect?

    Do I need to explicitly enable the custom action using some other REST API?

    Are there other certain criteria/conditions in the CommandUIExtention that if not met will automatically disable the button besides the EnabledScript attribute?

    What process takes place on app install when Sharepoint adds the User Custom Action by interpreting the Elements.xml from the module that is different from the process when calling the REST API service endpoint? Maybe there is a certain step that app installation handles automatically that the REST api does not and it just isn't documented in MSDN?


    Saturday, March 15, 2014 6:40 AM

Answers

  • Hi,

    I don't understand your answer: "it seems to have enablescript in your environment quite not possible based on your description". My environment is O365. Are you saying the EnableScript attribute is not possible in O365? 

    I reviewed many of those links you provided, none of them show someone successfully creating a Custom Action in the Ribbon using JavaScript REST API's.  That is the solution I am looking for.

    For instance, here is a partial view of the request I make with javascript:

    data: {
    	CommandUIExtension: "<CommandUIExtension xmlns="http://schemas.microsoft.com/sharepoint/">
    	<CommandUIDefinitions>
    		<CommandUIDefinition Location="Ribbon.ListItem.New.Controls._children">
    			<Button
    				Alt="SP2013 Custom Action"
    				Command="MyCommand" Id="Ribbon.ListItem.New.Controls._children_Button1395236322452"
    				Image16by16="_layouts/15/images/placeholder16x16.png"
    				Image32by32="_layouts/15/images/placeholder32x32.png"
    				LabelText="SP2013 Custom Action"
    				Sequence="101"
    				TemplateAlias="o1"/>
    		</CommandUIDefinition>
    	</CommandUIDefinitions>
    	<CommandUIHandlers>
    		<CommandUIHandler
    			Command="MyCommand"
    			CommandAction="javascript:alert('button clicked')"/>
    	</CommandUIHandlers>
    </CommandUIExtension>"
    	Description: null
    	Group: null
    	ImageUrl: null
    	Location: "CommandUI.Ribbon"
    	ScriptBlock: null
    	ScriptSrc: null
    	Sequence: 10001
    	Title: "SP2013 Custom Action"
    	Url: null
    },
    headers: {
    	Accept: "application/json; odata=verbose"
    	X-RequestDigest: "< removed >"
    	content-type: "application/json; odata=verbose"
    },
    method: "POST"

    I re-tested my SharePoint-hosted app this morning and the actions that I had created 4 days ago which were disabled as you saw in the screenshot are now showing as enabled.  I am very confused as to why they are working now, because I have not made any changes to the code.  Unless there was some recent update to O365 which affects custom actions I do not know what has changed from 4 days ago to now. 

    I even tested adding new actions using the application to try to reproduce the issue of them being disabled initially and then becoming enabled over time, but they are enabled as well.  I can't explain why it's working now, but I guess it is at least good that it is working. I will re-post if I find out what the issue was. 

    Also, Aries, you mentioned "use our sharepoint internal group tools". Can you send me more information about these internal tools? (my alias is mattm) I was not aware of anything other than Yammer, or email DL's.

    Wednesday, March 19, 2014 1:58 PM

All replies

  • Hi,

    I am trying to involve someone familiar with this topic to further look at this issue. There might be some time delay. Appreciate your patience.

    Best regards


    Dennis Guo
    TechNet Community Support

    Wednesday, March 19, 2014 3:03 AM
    Moderator
  • Hi Matt,

    regarding the button, i believe its quite different between the javascript and the visualstudio one, perhaps you may need to check the xml for make sure of this property.

    anyway, it seems to have enablescript in your environment quite not possible based on your description,

    http://sharepointnadeem.blogspot.in/2011/08/approve-multiple-items-in-document.html

    http://dannyjessee.com/blog/index.php/2013/01/javascript-to-conditionally-enable-a-sharepoint-custom-ribbon-button/

    http://sharepoint.stackexchange.com/questions/72089/custom-button-added-in-ribbon-is-disabled

    http://www.ilikesharepoint.de/2013/02/sharepoint-2010-disable-custom-action-button-if-selected-item-is-a-folder/

    http://koenvosters.wordpress.com/2009/11/05/howto-add-a-button-to-the-ribbon-in-sharepoint-2010/

    http://sharepointroot.com/2010/06/18/remove-actions-from-the-ribbon-sharepoint-2010/

    for more details, i believe you should use our sharepoint internal group tools, so that we can help you more detail regarding this issue.


    Regards,
    Aries
    Microsoft Online Community Support


    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.

    Wednesday, March 19, 2014 9:14 AM
  • Hi,

    I don't understand your answer: "it seems to have enablescript in your environment quite not possible based on your description". My environment is O365. Are you saying the EnableScript attribute is not possible in O365? 

    I reviewed many of those links you provided, none of them show someone successfully creating a Custom Action in the Ribbon using JavaScript REST API's.  That is the solution I am looking for.

    For instance, here is a partial view of the request I make with javascript:

    data: {
    	CommandUIExtension: "<CommandUIExtension xmlns="http://schemas.microsoft.com/sharepoint/">
    	<CommandUIDefinitions>
    		<CommandUIDefinition Location="Ribbon.ListItem.New.Controls._children">
    			<Button
    				Alt="SP2013 Custom Action"
    				Command="MyCommand" Id="Ribbon.ListItem.New.Controls._children_Button1395236322452"
    				Image16by16="_layouts/15/images/placeholder16x16.png"
    				Image32by32="_layouts/15/images/placeholder32x32.png"
    				LabelText="SP2013 Custom Action"
    				Sequence="101"
    				TemplateAlias="o1"/>
    		</CommandUIDefinition>
    	</CommandUIDefinitions>
    	<CommandUIHandlers>
    		<CommandUIHandler
    			Command="MyCommand"
    			CommandAction="javascript:alert('button clicked')"/>
    	</CommandUIHandlers>
    </CommandUIExtension>"
    	Description: null
    	Group: null
    	ImageUrl: null
    	Location: "CommandUI.Ribbon"
    	ScriptBlock: null
    	ScriptSrc: null
    	Sequence: 10001
    	Title: "SP2013 Custom Action"
    	Url: null
    },
    headers: {
    	Accept: "application/json; odata=verbose"
    	X-RequestDigest: "< removed >"
    	content-type: "application/json; odata=verbose"
    },
    method: "POST"

    I re-tested my SharePoint-hosted app this morning and the actions that I had created 4 days ago which were disabled as you saw in the screenshot are now showing as enabled.  I am very confused as to why they are working now, because I have not made any changes to the code.  Unless there was some recent update to O365 which affects custom actions I do not know what has changed from 4 days ago to now. 

    I even tested adding new actions using the application to try to reproduce the issue of them being disabled initially and then becoming enabled over time, but they are enabled as well.  I can't explain why it's working now, but I guess it is at least good that it is working. I will re-post if I find out what the issue was. 

    Also, Aries, you mentioned "use our sharepoint internal group tools". Can you send me more information about these internal tools? (my alias is mattm) I was not aware of anything other than Yammer, or email DL's.

    Wednesday, March 19, 2014 1:58 PM
  • Hi Matt, 

    I have this problem before, the issue was with the Cache, if you make a Clear Browse cache in IE, after that should work fine.

    You can see that if you switch to another browser should work fine but you see disable in IE.


    André Lage Microsoft SharePoint, CRM Consultant
    Blog:http://aaclage.blogspot.com
    Codeplex:http://spupload.codeplex.com/http://simplecamlsearch.codeplex.com/

    Monday, May 19, 2014 10:45 PM
  • Hi,

    I also struggled with this issue for two days and solution was just clear the cache.

    Clear your browser cache and it would work fine. 

    Friday, April 8, 2016 5:56 AM
  • VermaRaj, you're so right - it was a cache issue for me as well.  Thanks!
    Thursday, May 12, 2016 8:33 PM