Today I had a need to add a link to a page which would create a new document. The document library that I use has multiple content types and each content type has a custom document template.


Rather than asking the users to click on the New document menu options I want a single button on the page that looks like this:



So first within a content editor on my page.



Then I created  a link in my html that looks like this:

<a onclick="CoreInvoke('createNewDocumentWithRedirect2',event,'https:\u002f\\u002fShared Documents\u002fForms\u002fNon-Disclosure%20Agreement\u002fNDATemplate.docx', 'https:\u002f\\u002fShared Documents\u002fNon-Disclosure Agreement', 'SharePoint.OpenDocuments', false, ' /', true, 1); return false;" href="#">New NDA</a>

Ok, so on clicking the link  the following JavaScript is happening:

CoreInvoke('createNewDocumentWithRedirect2',event,'https:\u002f\\u002fShared Documents\u002fForms\u002fNon-Disclosure%20Agreement\u002fNDATemplate.docx', 'https:\u002f\\u002fShared Documents\u002fNon-Disclosure Agreement', 'SharePoint.OpenDocuments', false, 'https:/ / /', true, 1)

Ok, what does this all mean.

createNewDocumentWithRedirect2 – Is the function that is responsible for the opening Word.

event – this contains the event information of the as part of the onclick event.

https:\u002f\\u002fShared Documents\u002fForms\u002fNon-Disclosure%20Agreement\u002fNDATemplate.docx – This is my document template that I uploaded for my content type.

https:\u002f\\u002fShared Documents\u002fNon-Disclosure Agreement – This is the folder to my content type in the library.

SharePoint.OpenDocuments – SharePoint’s code to open documents

false – Not sure – This is the page that SharePoint calls to create new documents

true – Not sure

1 – Not sure






Avatar for Pieter Veenstra

By Pieter Veenstra

Business Applications and Office Apps & Services Microsoft MVP working as a Microsoft Productivity Principal Consultant at HybrIT Services. You can contact me using

4 thoughts on “SharePoint – Adding links on a page to create new documents using content types”
  1. Hi There,

    Thanks for sharing this. I’ve sadly had no joy at all getting this to work though.

    I’m trying to add a button to a page, that performs the (NEW ITEM) function for a doc library with an Infopath tempate (xsn).

    Perhaps because your example above was WORD this fails for me.

    Cannot find any explanation on web anywhere how to do this, so frustrating!

    Kind Regards,

  2. Hi Peter,
    I got the Invoke command out of the html on the library new menu.I’m not 100% if this will be the same for InfoPath forms. The best way forward is to put your browser in debug ( F12 for most browsers) and then identify the html that has the onclick event specified.

    I currently don’t have an InfoPath form handy.I might be able to have a look into that later this week.

  3. Thanks Pieter, I have been using Firebug to try and work out the JS needed. (I’m not a programmer! 🙂 )

    I managed to grab the HTML code for the default “NEW +” button for the doc library (with the Infopath template) and put it on another page on the site (which seems to work if I hide an app part of the library on the same page).

    This opens the Infopath (in Infopath) which is fine.

    Ideally though I would like to put a link to open this Infopath Template from another Site Collection completely. There is no way the button code below would work. I guess I need some real custom code.

    Button code..

    <button title="Create a new document or folder in this library." class="ms-qcb-button js-listview-qcbNewButton js-callout-body js-qcb-button js-callout-launchPoint " id="QCB1_Button1" role="button" accesskey="n" onclick="Renderer.FunctionDispatcher.Execute(this,0,"itemClick",event,Renderer.FunctionDispatcher.GetObject(0))" type="button" aira-expanded="false">New</span></button>

    Many Thanks

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.