1

I have created Empty Element in an autohosted App and tried this code for element.xml then uploaded & deployed it to Office 365 but nothing happened, Is there another step I should take?

    <?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <CustomAction
   Id="CustomRibbon"
   Location="CommandUI.Ribbon"
   RegistrationId="101"
   RegistrationType="List"
   Title="Copy Item to Doc Lib">
    <CommandUIExtension>
      <CommandUIDefinitions>
        <CommandUIDefinition
         Location="Ribbon.Documents.Manage.Controls._children">
          <Button
           Id="Ribbon.Items.Manage.CustomRibbon"           
           Command="CopyItem"
           Image32by32="http://s17.postimage.org/trf3y2ui3/U32.png"
           LabelText="Copy Item"
           TemplateAlias="o1" />
        </CommandUIDefinition>
      </CommandUIDefinitions>
      <CommandUIHandlers>
        <CommandUIHandler Command="CopyItem" CommandAction="javascript:alert('Hello world!');" />
      </CommandUIHandlers>
    </CommandUIExtension>
  </CustomAction>
</Elements>
1

Just want to mention something upfront, Autohosted apps will no longer be available at the end of the month. Microsoft is putting an end to them, and developers will no longer be able to deploy them. Currently running apps will continue to run for a short time, but are expected to be taken down as well.

Ribbons cannot contain JavaScript in them. That you were able to deploy the app without error is surprising. Try adding the JavaScript to a page, and then pointing to that page in your CommandUIHandler element:

<CommandUIHandler
    Command="Invoke_CustomAction"
    CommandAction="~remoteAppUrl/CustomActionTarget.aspx?HostUrl={HostUrl}&amp;Source={Source}&amp;ListURLDir={ListUrlDir}&amp;SelectedListID={SelectedListId}&amp;SelectedItemID={SelectedItemId}"/>
</CommandUIHandlers>

See this link for more info on creating a custom action. This link lists and explains all the tokens you can use in the query string.

| improve this answer | |

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.