Link to Create Instance of Content Type

Sometime, you want to give your user a link to create a document in a library somewhere using a document template tied to one of the library’s content types.

Our new best friends at SharePointKings.com gave us a head start on figuring it out. I just had to pull out my ASCII character map to decode all the escape characters and found they mostly didn’t matter.  So, using our handy dandy content editor web part, we can drop this code in place to cross this one off our list:

<A onfocus="OnLink(this)" HREF="XXX Item 1 XXX" onclick=
"createNewDocumentWithProgID('XXX ITEM 2 XXX', 'XXX ITEM 3 XXX',
'SharePoint.OpenDocuments', false)">Create Instance of Content
Type in Specified Library</A>

Just replace my place holders as follows:

“XXX ITEM 1 XXX” = Relative path to template in \Site\Subsite\library\forms\content type\ folder, i.e.

"/SiteDirectory/My%20Site/My%20Library/Forms/My%20Content%20Type/
Template%20File%20Name.docx"

 I’m using %20 for blank spaces. You can browse to the folder in Explorer view to be sure you have it right. Just swap the \s in favor of /s

‘XXX ITEM 2 XXX’ = Full path to template in \content type folder. In my example above, that would be:

'http://MyDomain.com//SiteDirectory/My%20Site/My%20Library/
Forms/My%20Content%20Type/Template%20File%20Name.docx'

Use single quotes.

‘XXX ITEM 3 XXX’ = Full path to host library. In my example above, that would be:

'http://MyDomain.com//SiteDirectory/My%20Site/My%20Library'.

Again use single quotes.

I’m not sure what the OnFocus= does for us and I can’t testify to the efficacy of the relative vs. full paths but this format does the trick for me.

hth
-robot


Tags:

 
 
 

Comments are closed.