I need to Open/Download Word or PowerPoint Document directly from Provider Hosted SharePoint App. We can perform easily in on-premise using editDocumentWithProgID2
Tried with getting CORE.js, SP.js and other related js files from 15 hive and placed in solution with referencing inside the aspx page.
<script src="../Scripts/js/SP.Init.js"></script>
<script src="../Scripts/js/SP.Core.js"></script>
<script src="../Scripts/js/SP.Runtime.js"></script>
<script src="../Scripts/js/SP.js"></script>
<script src="../Scripts/js/CORE.JS"></script>
This below function is called on anchor tag in javascript.
function EditDocumentFile(filename) {
editDocumentWithProgID2(filename, '', 'SharePoint.OpenDocuments', '0', '/', '0');
}
function editDocumentWithProgID2(strDocument, varProgID, varEditor, bCheckout, strhttpRoot, strCheckouttolocal) {
var sURL = unescape(window.location.pathname);
window.location.href = sURL;
var errorCode = editDocumentWithProgIDNoUI(strDocument, varProgID, varEditor, bCheckout, strhttpRoot, strCheckouttolocal);
if (errorCode == 1) {
alert(L_EditDocumentRuntimeError_Text);
window.onfocus = RefreshOnNextFocus;
}
else if (errorCode == 2)
alert(L_EditDocumentProgIDError_Text);
}
Not working and shows error:
Uncaught ReferenceError: unescapeProperly is not defined
in browser developer tool console.
Any idea how to work with editDocumentWithProgID2 in CSOM ?