Question

I've been asked to check if it is possible to trigger the creation of a new document linked to a content type. Like, to make it simple, you have a webpart, a button, you click it, and it opens the document template with the Document Information Panel ready to add your metadatas.

Is it possible to trigger this in C# ?

Thank you

Was it helpful?

Solution

SharePoint invokes that with JavaScript

CoreInvoke('createNewDocumentWithRedirect2',event,'http:.... //there are more parameters with site Url, document template Url etc.

so you can do it the same way.

Open the default view in a browser and view the source. Search for "Create a new 'YourContentType'", take CoreInvoke() and use it with an A tag. It should look like this

<a onclick="CoreInvoke(&#39;createNewDocumentWithRedirect2&#39;,event,&#39;http:\u002f\u002f<yoursitename>\u002fShared Documents\u002fForms\u002fNew Word Document\u002fDocTemplate.dotx&#39;, &#39;http:\u002f\u002f<yoursitename>\u002fShared Documents\u002fNew Word Document&#39;, &#39;SharePoint.OpenDocuments&#39;, false, &#39;http://<yoursitename>/_layouts/CreateNewDocument.aspx?id=http://<yoursitename>/Shared%20Documents/Forms/New%20Word%20Document/DocTemplate.dotx&#39;, true, 1); return false;" href="#">Word 2010</a>

Use that in a content editor web part or call it from your code behind.

Check this article

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top