none
Need to open app web in dialog box instead of full page, when i click button in ribbion control in sharepoint online. RRS feed

  • Question

  • Need to open app web in dialog box instead of full page, when i click button in ribbion  control in sharepoint online.  i developed the Custom action using sharepoint hosted app
    Friday, November 8, 2019 4:28 AM

All replies

  • Hi ,

    For SharePoint add-in custom action, it contains url only, no JavaScript.

    https://docs.microsoft.com/en-us/sharepoint/dev/sp-add-ins/sharepoint-add-ins-ux-design-guidelines?redirectedfrom=MSDN#adding-custom-actions-to-the-host-web

    CustomAction cannot contain JavaScript:

    • Any UrlActions or CommandActions must be a URL to navigate to. The URL can be parameterized with normal custom actions tokens in addition to the app-specific tokens.
    • EnabledScript is not allowed in ribbon customizations.

    You could use HostWebDialog attribute for classic view(modern view won’t support).

    Demo:

    <?xml version="1.0" encoding="utf-8"?>
    <Elements xmlns="http://schemas.microsoft.com/sharepoint/">
      <CustomAction Id="ca80595b-305c-49f1-8207-d1a3657bd223.LeeRibbonCA"
                    RegistrationType="List"
                    RegistrationId="{$ListId:Lists/List1;}"
                    Location="CommandUI.Ribbon"
                    Sequence="10001"
                    HostWebDialog="TRUE"
                    HostWebDialogWidth="600"
                    HostWebDialogHeight="400"
                    Title="Invoke &apos;LeeRibbonCA&apos; action">
        <CommandUIExtension>
          <!-- 
          Update the UI definitions below with the controls and the command actions
          that you want to enable for the custom action.
          -->
          <CommandUIDefinitions>
            <CommandUIDefinition Location="Ribbon.ListItem.Manage.Controls._children">
              <Button Id="Ribbon.ListItem.Manage.LeeRibbonCAButton"
                      Alt="Request LeeRibbonCA"
                      Sequence="100"
                      Command="Invoke_LeeRibbonCAButtonRequest"
                      LabelText="Request LeeRibbonCA"
                      TemplateAlias="o1"
                      Image32by32="_layouts/15/images/placeholder32x32.png"
                      Image16by16="_layouts/15/images/placeholder16x16.png" />
            </CommandUIDefinition>
          </CommandUIDefinitions>
          <CommandUIHandlers>
            <CommandUIHandler Command="Invoke_LeeRibbonCAButtonRequest"
                              CommandAction="~appWebUrl/Pages/Default.aspx?{StandardTokens}&amp;SPListItemId={SelectedItemId}&amp;SPListId={SelectedListId}"/>
          </CommandUIHandlers>
        </CommandUIExtension >
      </CustomAction>
    </Elements>
    

    Add  <WebPartPages:AllowFraming runat="server" /> to allow iframe.

    <asp:Content ContentPlaceHolderID="PlaceHolderMain" runat="server">
        <WebPartPages:AllowFraming runat="server" />


    Best Regards,

    Lee


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    SharePoint Server 2019 has been released, you can click here to download it.
    Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.

    Friday, November 8, 2019 9:11 AM
  • If i switch to  classic view iam getting below error

    

    Saturday, November 9, 2019 9:18 AM
  • getting error  " refuse" to connect
    Saturday, November 9, 2019 9:19 AM
  • Hi,

    Have you added AllowFraming in your aspx page?

    <WebPartPages:AllowFraming runat="server" />

    Best Regards,

    Lee


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    SharePoint Server 2019 has been released, you can click here to download it.
    Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.

    Monday, November 11, 2019 1:03 AM