3

We are using SharePoint 2013 for intranet portal. Not apps.

We have a document library with documents. On clicking the document we get it opened in a modal popup.

On the ribbon of this display form I want to place a clickable item on the ribbon such that, when we click on it, then I want to redirect to an application page with this doc id.

I would also like to know the number of possible ways to do this and the best practice.

3

This can be done by creating a CustomAction. Specify Location="CommandUI.Ribbon.DisplayForm" in order to place a button in Display form. Here is an example:

<CustomAction
    Id="ExportVersionHistory.DisplayForm"
    RegistrationType="ContentType"
    RegistrationId="0x01"
    Location="CommandUI.Ribbon.DisplayForm"
    Rights="ViewListItems">
        <CommandUIExtension>
            <CommandUIDefinitions>
                <CommandUIDefinition
                 Location="Ribbon.ListForm.Display.Manage.Controls._children">
                    <Button
                     Id="Ribbon.ListForm.Display.Manage.Controls.ExportVersionHistory"
                     Alt="Export version history of the item to Microsoft Excel."
                     LabelText="Export Version History"
                     Image16by16="/_layouts/15/images/NY.ExportVersionHistory/Excel_Small.png"
                     Image32by32="/_layouts/15/images/NY.ExportVersionHistory/Excel_32.gif"
                     Command="ExportVersionHistory"
                     Sequence="99"
                     TemplateAlias="o1"
                     ToolTipTitle="Export Version History"
                     ToolTipDescription="Export version history of the item to Microsoft Excel."/>
                </CommandUIDefinition>
            </CommandUIDefinitions>
            <CommandUIHandlers>
                <CommandUIHandler
                 Command="ExportVersionHistory"
                 CommandAction="~site/_layouts/15/NY.ExportVersionHistory/ExportVersionHistory.aspx?List={ListId}&amp;ID={ItemId}"
                 EnabledScript="javascript:ExportVersionHistoryDisplayFormEnable();"/>
            </CommandUIHandlers>
        </CommandUIExtension>
</CustomAction>
  • Where is this code written? DispForm.aspx? – ExceptionLimeCat Mar 2 '15 at 20:03
  • it is written in the element .xml of custom action. You can create the custom action by adding an EmptyElement template in vs2010. – Deepika Mar 26 '15 at 9:19

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.