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:

newnda

 

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\u002fportal.mycorp.com\u002fShared Documents\u002fForms\u002fNon-Disclosure%20Agreement\u002fNDATemplate.docx’, ‘https:\u002f\u002fportal.mycorp.com\u002fShared Documents\u002fNon-Disclosure Agreement’, ‘SharePoint.OpenDocuments’, false, ‘https://portal.mycorp.com/_layouts/CreateNewDocument.aspx?id=https://portal.mycorp.com/Shared%20Documents/Forms/Non-Disclosure%20Agreement/NDATemplate.docx&#8217;, true, 1); return false;” href=”#”>New NDA</a>

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

CoreInvoke(‘createNewDocumentWithRedirect2‘,event,’https:\u002f\u002fportal.mycorp.com\u002fShared Documents\u002fForms\u002fNon-Disclosure%20Agreement\u002fNDATemplate.docx‘, ‘https:\u002f\u002fportal.mycorp.com\u002fShared Documents\u002fNon-Disclosure Agreement‘, ‘SharePoint.OpenDocuments‘, false, ‘https://portal.mycorp.com/_layouts/CreateNewDocument.aspx?id=https://portal.mycorp.com/Shared%20Documents/Forms/Non-Disclosure%20Agreement/NDATemplate.docx‘, 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\u002fportal.mycorp.com\u002fShared Documents\u002fForms\u002fNon-Disclosure%20Agreement\u002fNDATemplate.docx – This is my document template that I uploaded for my content type.

https:\u002f\u002fportal.mycorp.com\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

https://portal.mycorp.com/_layouts/CreateNewDocument.aspx?id=https://portal.mycorp.com/Shared%20Documents/Forms/Non-Disclosure%20Agreement/NDATemplate.docx – This is the page that SharePoint calls to create new documents

true – Not sure

1 – Not sure

 

 

 

 

 

Advertisements