Does anyone have any experience with controlling the redirect when creating a new document set with NewDocSet.aspx?

Our client would like the ability to create a new document set and be returned to a page (most likely the page the form was entered from), instead of being taken to the document set.

We have had no success using the source query string parameter. On save it takes us to the document set view

https://[sitecollectionurl]/_layouts/15/NewDocSet.aspx?List=[listid]&ContentTypeId=[contenttypeid]&RootFolder=[folder]&Source=[site homepage.aspx]

Nor have we had any luck with using modal dialogs, the save button never goes through the dialogReturnValueCallback function and redirects the entire page (not just the dialog) to the document set view. The cancel button and the close form button does.

ShowDialog = function() {
var options = {
        title: "New Dialog",
        autosize: true,
        showClose: true,
        url: SP.Utilities.UrlBuilder.urlCombine(_spPageContextInfo.webServerRelativeUrl, "[same url as above]&isDlg=1"),
        dialogReturnValueCallback: DialogSave,

DialogSave = function(dialogResult, returnValue) {

This is on Sharepoint 2013 on-prem

Any ideas?

2 Answers 2


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


I have the opposite problem - I am finding that, after customizing NewDocSet.aspx, I am no longer being redirected into the Doc Set after creation, and it's redirecting back to the parent library instead.

So I would suggest following the steps in the below post to get the behavior you want.

Customize NewDocSet.aspx form?

Edit: The behavior that occurs after you create a Document Set is controlled by the assemblies loaded by the form. The default form NewDocSet.aspx registers the following assembly: Microsoft.Office.DocumentManagement.Pages, and inherits a set of methods from the class Microsoft.Office.DocumentManagement.Pages.NewDocSet:

<%@ Assembly Name="Microsoft.Office.DocumentManagement.Pages, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c"%>
<%@ Page Language="C#" DynamicMasterPageFile="~masterurl/default.master" Inherits="Microsoft.Office.DocumentManagement.Pages.NewDocSet" 

This file (Microsoft.Office.DocumentManagement.Pages.dll) is located on the Server at

C:\Program Files\Common Files\microsoft shared\Web Server Extensions\16\CONFIG\BIN\

One of the class methods for ~DocumentManagement.NewDocSet is OKBtn_Click, which is referenced in NewDocSet.aspx by the "Save" button's onclick attribute:

<asp:button class="ms-ButtonHeightWidth" runat="server" text="<%$Resources:wss,multipages_savebutton_text%>" onclick="OKBtn_Click" id="btnOK" />

The OkBtn_Click method handles creation of the Document Set, passing off control to other methods to validate, etc. At the very end of the method, there is code that redirects the user to the Welcome Page of the newly created Document Set (retrieved using ILSpy):

string a = base.Request.QueryString["Sync"];
if (a == "1")
    using (SPLongOperation sPLongOperation = new SPLongOperation(this))
        DocumentSet documentSet = DocumentSet.Create(parentFolder, name, ctid, properties, bProvisionDefaultContent: true, (SPUser)null, (SPLongOperationState)null);
        string welcomePageUrl = documentSet.WelcomePageUrl;
        if (base.IsDialogMode)
            sPLongOperation.EndScript("window.frameElement.navigateParent('" + SPHttpUtility.EcmaScriptStringLiteralEncode(welcomePageUrl) + "');");
        sPLongOperation.End(welcomePageUrl, SPRedirectFlags.Default, Context, null);
    SPStatefulLongOperation.Begin("", DocumentSet.ProgressHtml, delegate(SPStatefulLongOperation longOperation)
        DocumentSet docset = null;
        longOperation.Run(delegate(SPLongOperationState longOperationState)
            docset = DocumentSet.Create(parentFolder, name, ctid, properties, bProvisionDefaultContent: true, (SPUser)null, longOperationState);
        string welcomePageUrl2 = docset.WelcomePageUrl;
        if (base.IsDialogMode)
            longOperation.EndScript("window.frameElement.navigateParent('" + SPHttpUtility.EcmaScriptStringLiteralEncode(welcomePageUrl2) + "');");
        longOperation.End(welcomePageUrl2, SPRedirectFlags.Default, Context, null);

What this appears to show is that the method used by the "Save" button is what makes the difference. Hence in my case, where I am using a "custom" Document Set New Form based on a generic List New Form, the OKBtn_Click method is never called and hence the redirection logic is different.

Kudos to this blog post for helping me to figure out the above.

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.