Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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

2 Answers 2

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

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=" +
                customEncode(listId)
                + "&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;
        }

</script>

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

share|improve this answer

We're looking for long answers that provide some explanation and context. Don't just give a one-line answer; explain why your answer is right, ideally with citations. Answers that don't include explanations may be removed.

1  
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 at 11:03
    
Please don’t add just a link as answer to a question. If the link breaks, the answer you provided will not be useful for future visitors. Provide an answer of your own and use the link as reference. If needed, you can block quote the content from your link. More information is found in our help center, especially How do I write a good answer –  Benny Skogberg Jul 22 at 12:51

Your Answer

 
discard

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.