Has anybody succesfully been able to open a dialog from a custom action on the ribbon on top of another dialog?

The use case that I have a list, which already opens in dialog. On the dispform.aspx i have a custom action in the ribbon. When I click the action an edit form from another lists open in dialog. However in does not open op top of the exsisting list, but rather replaces the existing dialog.

  • how did you create the custom action in the ribbon?
    – Ali Jafer
    Commented Dec 18, 2017 at 10:46
  • Using SharePoint designer. I would prefer not messing with the xml.
    – Morten K
    Commented Dec 18, 2017 at 10:58

1 Answer 1


You could add custom action to open modern dialog by JSOM.

Here is my test sample code.

<script src="https://code.jquery.com/jquery-1.9.1.min.js" type="text/javascript"></script>
    <script language="javascript" type="text/javascript">

        //$(document).ready(function() {
        //    SP.SOD.executeOrDelayUntilScriptLoaded(AddCustomUserAction, "sp.js");
        //var oListItem;

        function AddCustomUserAction() {
            //Get the client context and list object
            var context = new SP.ClientContext.get_current();
            var list = context.get_web().get_lists().getByTitle("dialog");
            //Get the custom user action collection and add the user action
            var customUserAction = list.get_userCustomActions().add();
            //Set the location of the user action
            //Add the properties for the custom action
            var userActionExtension = '<CommandUIExtension xmlns="http://schemas.microsoft.com/sharepoint/">' + '<CommandUIDefinitions>' + '<CommandUIDefinition Location="Ribbon.ListForm.Display.Manage.Controls._children">' + '<Button Id="Ribbon.Documents.New.RibbonTest" ' + 'Command="CustomDialog" ' + 'Sequence="0" ' + 'Image16by16="/_layouts/images/NoteBoard_16x16.png" ' + 'Image32by32="/_layouts/images/NoteBoard_32x32.png" ' + 'Description="DialogTest" ' + 'LabelText="DialogTest" ' + 'TemplateAlias="o1"/>' + '</CommandUIDefinition>' + '</CommandUIDefinitions>' + '<CommandUIHandlers>' + '<CommandUIHandler Command="CustomDialog" ' +
            'CommandAction="javascript:SP.UI.ModalDialog.showModalDialog({ url: &#34;/SitePages/Forms/AllPages.aspx?isdlg=1&#34;, title: &#34;Custom Dialog&#34;,showClose: true });" />' + '</CommandUIHandlers>' + '</CommandUIExtension>';
            //Add the command UI extension and update the custom user action
            //Load the client context and execute the batch
            context.load(list, 'UserCustomActions');
            context.executeQueryAsync(function () {
                console.log("Custom User Action added successfully to ribbon.");
            }, function (sender, args) {
    <input id="Button1" onclick="AddCustomUserAction()" type="button" value="button" />

enter image description here Referenced thread.


  • I'm having a bit of trouble getting it to work. Can I ask if your solution has been tested on SP 2016? In the console I can see, it is supposed to have loaded the custom action, but that doesn't seem to be the case.
    – Morten K
    Commented Dec 22, 2017 at 12:34
  • Oh well I figured out i can just add the javascript in the link part in SPD: javascript:SP.UI.ModalDialog.showModalDialog({ url: "MY LINK", title: "Custom Dialog",showClose: true }); Works like a charm - thanks a lot!
    – Morten K
    Commented Dec 22, 2017 at 12:59

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.