1

I have the following custom action declaration:

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<CustomAction Id="17f8cf1d-c8bf-4721-986b-d4106d77343c.RibbonCustomAction2"
            Location="CommandUI.Ribbon"
            Sequence="10001"
            HostWebDialog="true" 
            HostWebDialogHeight="300" 
            HostWebDialogWidth="300"
            Title="Dialog Title">   
<CommandUIExtension>
  <CommandUIDefinitions>
    <CommandUIDefinition Location="Ribbon.EditingTools.CPInsert.Content.Controls._children">
      <Button Id="Ribbon.WikiPageTab.PageActions.RibbonCustomAction2Button"
              Alt="Invoke RibbonCustomAction2" 
              Sequence="100" 
              Command="Invoke_RibbonCustomAction2ButtonRequest"
              LabelText="CustomAction2"
              TemplateAlias="o1"
              Image32by32="_layouts/15/images/placeholder32x32.png"
              Image16by16="_layouts/15/images/placeholder16x16.png" />
    </CommandUIDefinition>
  </CommandUIDefinitions>
  <CommandUIHandlers>
    <CommandUIHandler Command="Invoke_RibbonCustomAction2ButtonRequest"
                      CommandAction="~appWebUrl/Pages/Image.aspx?listId={ListId}&amp;selectedListId={SelectedListId}&amp;itemId={ItemId}&amp;selectedItemId={SelectedItemId}"/>
  </CommandUIHandlers>
</CommandUIExtension >
</CustomAction>
</Elements>

Custom action works and is displayed in Insert tab for Publising Pages, but I can't get the current Page Library and Page Ids. Parameters passed to Image.aspx:

?listId={ListId}&selectedListId=null&itemId={ItemId}&selectedItemId=null&IsDlg=1

1 Answer 1

0

I don't think these parameters are picked up from the QueryString. They are related to current selected item. https://msdn.microsoft.com/en-us/library/ms473643(v=office.12).aspx.

Your best bet would be to write some javascript in the handler as described over here https://msdn.microsoft.com/en-us/library/office/ff458385.aspx

Within the javascript function, you can get the query string and parse it to get what you need.

Regards

1
  • Unfortunately, according to msdn.microsoft.com/en-us/library/jj220046.aspx "CustomAction cannot contain JavaScript" in Apps for Sharepoint. When I try to write simple "javascript:alert('Hello');" I get "Error occurred in deployment step 'Install app for SharePoint': There were errors when validating the App Package." Commented May 21, 2015 at 7:58

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.