I have a wiki page with a link on it which when clicked opens a modal dialog to a document set's new form page.

When the Cancel button on the modal dialog is clicked, the dialog closes, as expected.

But when the Save button is clicked, the modal closes and the page redirects to the new document set's home page.

How can I have the modal dialog simply close when the Save button is clicked, rather than redirect to the document set's home page?

var options = 
        url: dialogUrl,
        allowMaximize: dialogAllowMaximize,
        showClose: dialogShowClose,
        width: dialogWidth,
        height: dialogHeight,
        title: dialogTitle,
        dialogReturnValueCallback: function(dialogResult) 
          SP.UI.ModalDialog.RefreshPage(dialogResult) //This will refresh the current page if "Ok" is returned. You can just return false here.

Use dialogReturnValueCallback to call your own delegate once modal dialog exits.

  • Doesn't seem to work. When clicking the Save button the page still redirects to the document set's home page. But the callback is definitely called, as I've confirmed with a simple log to the console when clicking the Cancel button. Also tried return false; without success. – Submits Jan 27 '16 at 14:02

Did you ever find a Sharepoint focussed solution @Submits?

This is not the prettiest method, nor is it Sharepoint focused but it works fairly well if you know where you are attempting to add doc sets from

We added a script editor webpart above the image on the document set welcome page so that it is called as early as possible during page load

(function () {
   if (document.referrer === 'https://sharepoint.com/sourcepage.aspx') {
      window.location = 'https://sharepoint.com/sourcepage.aspx'

With this it gets halfway through loading the doc set welcome page (only as far as header elements and left navigation) before bouncing back to the originating page. Granted it won't work as well if you have the modal dialog code in multiple places

Taken as a self-answer from my question here

  • I can't actually remember if I found a solution in the end. I suspect not, But thanks for coming here and providing a possible solution. Unfortunately I can't test your solution, but it may still help other users. – Submits Mar 30 '17 at 10:09

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.