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 contennewdoct 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 folloing 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, ‘‘, 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