Add links to Create new document and edit existing document in document library using javascript

Link to Create new document in document library using documenttemplate of content type

docUrl = “CoreInvoke(‘createNewDocumentWithRedirect2’,event,'”http:\\serverurl\sites\sitename\u002fDocuments\u002fForms\u002f” + contentTypeName + “\u002f” + docTemplateName + “‘, ‘http:\\serverurl\sites\sitename\u002fDocuments’, ‘SharePoint.OpenDocuments’, false, ‘http:\\serverurl\sites\sitename\u002f_layouts\u002fCreateNewDocument.aspx?id=http:\\serverurl\sites\sitename\u002fDocuments\u002fForms\u002f” + contentTypeName + “\u002f” + docTemplateName + “‘, true, 1); return false;”;

In the above line, ‘contentTypeName’ and ‘docTemplateName’ variables are used, get their values using Javascript CSOM

<a onclick='” + docUrl + “‘ href=’#’>Create new document</a>

 

Link to Edit existing document in document library

var url = “return DispEx(this,event,’TRUE’,’FALSE’,’FALSE’,’SharePoint.OpenDocuments.3′,’0′,

‘SharePoint.OpenDocuments’,”,”,”,’1′,’0′,’0′,’0x7fffffffffffffff’)”;

<a href='” + {fileUrl} + “‘ onclick=\”” + url + “\”>”

Replece {fileUrl} with the url of the document stored in document library.

 

———————————————————————————————————–

 

Trackbacks

Leave a Comment

Your email address will not be published. Required fields are marked *