1

I would create a custom ribbon in Sharepoint 2013. I created my APP-Sharepoint Hosted APP and I have added my Custom Ribbon . This Custom Ribbon, with a click under it, must open a dialog box or simply an alert.

I have used this code:

 <?xml version="1.0" encoding="utf-8"?>
    <Elements xmlns="http://schemas.microsoft.com/sharepoint/">
      <CustomAction
      Id="ShowHelloWorldButton"
      RegistrationType="ContentType"
      RegistrationId="0x01"
      Location="CommandUI.Ribbon.ListView"
      Rights="EditListItems">
        <CommandUIExtension>
          <CommandUIDefinitions>
            <CommandUIDefinition
             Location="Ribbon.ListItem.Actions.Controls._children">
              <Button
               Id="Ribbon.ListItem.Actions.Controls.ShowHelloWorldButton"
               Alt="Show HelloWorld Alert"
               Sequence="1"
               Image32by32="_layouts/15/images/placeholder32x32.png"
               Image16by16="_layouts/15/images/placeholder16x16.png" 
               Command="ShowHelloWorldCommand"
               LabelText="Hello World"
               TemplateAlias="o1"
               CommandType="General"/>
            </CommandUIDefinition>
          </CommandUIDefinitions>
          <CommandUIHandlers>
            <CommandUIHandler
             Command="ShowHelloWorldCommand"
             CommandAction="javascript:alert('Hello World');" />
          </CommandUIHandlers>
        </CommandUIExtension>
      </CustomAction>
    </Elements>

But I obtain this error:

Error occurred in deployment step 'Install app for SharePoint': There were errors when validating the App Package.

Why?

Thanks!

  • Do you get the error if you try to deploy without the custom action as well? – eirikb Apr 3 '14 at 13:25
  • Without custom action the custom ribbon there isn't :( – marco.de.santis83 Apr 3 '14 at 13:50
  • Could it be permission? Have you tried, just for the sake of testing, to give full control on web and lists? – eirikb Apr 3 '14 at 15:33
1

I solved in this way:

1- adding in CustomAction Element:

 HostWebDialog="true"
 HostWebDialogHeight="300"
 HostWebDialogWidth="400"

2 in CommandUIHandlers a reference to a webpage:

 <CommandUIHandler
      Command="CustomTabExample.MyCommand"
        CommandAction="~appWebUrl/Pages/ClientWebPartTest2.aspx?{StandardTokens}&amp;SPListItemId={SelectedItemId}&amp;SPListId={SelectedListId}" EnabledScript="javascript:SP.ListOperation.Selection.getSelectedItems().length > 0;" />

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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