SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've found this page which explains how to add a ‘Create New Document’ link to a page :

<img alt="" src="/_layouts/images/rect.gif">&nbsp;
<a onclick="createNewDocumentWithProgID('http:\u002f\u002fvm-moss2007\u002fMod Props\u002fForms\u002fMod Props\u002fModPropTemplate.xlsx', 'http:\u002f\u002fvm-moss2007\u002fMod Props', 'SharePoint.OpenDocuments', false);return false;" href="#">Create new Mod Prop</a>

My question is if it's also possible to add a link to a web-page which goes directly to the 'Add Document Set' functionality.

share|improve this question

Go to this link and check answer from tuddy86

Mod edit, copying content over so it isn't lost.

This is how I managed to have a link to new document set form, thx!

This is the script I needed to make it happen from javascript:

<script type="text/javascript">

        var list;
        var listRootFolder;
        ExecuteOrDelayUntilScriptLoaded(init, "sp.js");

        function init() {

            //load site
            var currentcontext = new SP.ClientContext.get_current();
            list = currentcontext.get_web().get_lists().getByTitle('Contracts');

            currentcontext.load(list, 'Id', 'ContentTypes');
            currentcontext.executeQueryAsync(Function.createDelegate(this, result), Function.createDelegate(this, oncListQueryFailed));

        function result() {
            var listId = list.get_id();
            var relativeURL = _spPageContextInfo.webServerRelativeUrl;

            var url = relativeURL + "/_layouts/15/NewDocSet.aspx?List=" +
                + "&RootFolder=" + customEncode(relativeURL + "/contracts")
                + "&ContentTypeId=" + getContractContentTypeId(list);
            $("a#myLink").attr("href", url);

        function oncListQueryFailed(sender, args) {
            alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());

        function getContractContentTypeId(list) {
            var ct_enumerator = list.get_contentTypes().getEnumerator();
            while (ct_enumerator.moveNext()) {
                var ct = ct_enumerator.get_current();

                var ctypeId = ct.get_id().toString();
                if (ctypeId.startsWith("0x0120D52000F5F4E351EDB84EE992DB1245916364BC")) {
                    return ctypeId;

        function customEncode(url) {
            url = encodeURIComponent(url);
            url = url.replace('.', '%2E');
            url = url.replace(/-/g, '%2D');
            return url;


I had a custom document set content type in my scenario...

share|improve this answer
I am afraid one liner or just link answers do not add any value. Would you please add some content or breif description on how to solve the problem. It will be helpful to other readers. – Asad Refai Jul 22 '15 at 11:03

The code below will allow you to perform a redirect to a given page when the user clicks on New Item

$("a[id$='NewMenu']").click(function(e) { window.location = '/_layouts/smartaudit/UploadAudit.aspx'; return false; });
share|improve this answer
Would you care to put some more context around that? How would you integrate that into the html snipped in the question? Where does the Document Set come in? – teylyn Jul 21 '13 at 23:57

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.