While working with SharePoint / JavaScript modal pop up you might encounter error "cannot read property 'showmodaldialog' of undefined". Here is simple solution for that.
Code Sample:
function OpenDocsDialog(url1) {
var options = {
url: url1,
dialogReturnValueCallback: myDialogCallback
};
SP.UI.ModalDialog.showModalDialog(options); // this line gives error.
}
Solution : We need to load "sp.js" file before calling above code. You can load "sp.js" file with below code sample:
ExecuteOrDelayUntilScriptLoaded(function () { //code }, "sp.js")
Full solutionExample :
function OpenDocsDialog(url1) {
var options = {
url: url1,
dialogReturnValueCallback: myDialogCallback
};
ExecuteOrDelayUntilScriptLoaded(function () {
SP.UI.ModalDialog.showModalDialog(options);
}, "sp.js")
}
Subscribe to:
Comments (Atom)
What is the Use of X and Y Properties in Power Apps SharePoint List Form?
If you've spent any time customizing SharePoint List Forms using Power Apps, you've likely come across the X and Y properties ...
-
Code Review :- General 1. Remove the commented code 2. Variable name should not be contain "_". 3. Query should be in separat...
-
In last blog we learn how can we enable footer on SharePoint Online Modern Communication site. If you have not gone through that you can use...
-
Issue : Recently, we had a requirement to sync the calendar between shared mailbox outlook and SharePoint Calendar list. We have created 2 f...