Last active
May 24, 2023 17:28
-
-
Save maxali/affdedde8cca2209759f2317ffbd2b5a to your computer and use it in GitHub Desktop.
Create Document Web App Modal
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
CreateDocument.aspx is in frame with window.frameElement.commitPopup(url) and cancelPopup() | |
Fix: | |
create window.on("message | createDocument") that | |
starts CreateDocument.aspx diaglog in context of SharePoint docLib page. | |
*/ | |
//Using a generic object. | |
var options = { | |
title: "My Dialog Title", | |
width: 400, | |
height: 600, | |
dialogReturnValueCallback: function(dialogResult, returnValue){ | |
console.log(dialogResult); | |
console.log(returnValue); | |
// if canceled dialogResult = 0, returnValue = null | |
// if created (OK clicked), dialogResult = 1 and returnValue = https://tenant.sharepoint.com/sites/site/_layouts/15/WopiFrame.aspx?sourcedoc=%2Fsites%2Fsite%2FShared%20Documents%2FCreated%20from%20Dialog%20Check%20Return%20Callback%2Edocx&action=editnew&IsDlg=1 | |
if(dialogResult === 1 ) { | |
location.href = returnValue; | |
// or __doPostBack() | |
} | |
}, | |
url:"https://tenant.sharepoint.com/sites/site/_layouts/15/CreateNewDocument.aspx"+ | |
"?id=https://tenant.sharepoint.com/sites/site/Shared Documents/Forms/template.dotx"+ | |
"&RootFolder=/sites/site/Shared Documents/For Admins&SaveLocation=/sites/site/Shared Documents"+ | |
"&IsDlg=1"+ | |
"&Source=/sites/site/Shared Documents" | |
}; | |
// window.postMessage("createDocument", {ur;"..."}) | |
SP.UI.ModalDialog.showModalDialog(options); | |
/* | |
After ModalDialog closed, run: | |
*/ | |
WebForm_DoPostBackWithOptions( | |
new WebForm_PostBackOptions( | |
"ctl00$PlaceHolderMain$buttonSectionMain$RptControls$buttonOK", | |
"", | |
true, | |
"", | |
"", // actionUrl !important | |
false, | |
true) | |
) | |
/**/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment