My SharePoint 2013 App has a button with the click Event:
OpenDialog("/Lists/ListName/NewForm.aspx?IsDlg=1");
where OpenDialog is defined the following way:
function OpenDialog(URL) {
var options = { url:URL, width: 600, height: 500, showClose: true, allowMaximize: true };
SP.UI.ModalDialog.showModalDialog(options);
}
The problem is, I get an Access Denied error when debugging, or without debugging the following screen:
When I click on the provided link, titled with "Open this content in a new window" the dialog is shown in a new window. But I want it to be opened as Dialog within my App.
Do I need to give some more permissions to the app or to any other part of it? What am I missing out?
UPDATE:
Just in case of missing permissions I tried the following:
<AppPermissionRequests>
<AppPermissionRequest Scope="http://sharepoint/content/sitecollection/web" Right="FullControl" />
<AppPermissionRequest Scope="http://sharepoint/content/sitecollection" Right="FullControl" />
<AppPermissionRequest Scope="http://sharepoint/projectserver" Right="Manage" />
<AppPermissionRequest Scope="http://sharepoint/projectserver/enterpriseresources" Right="Write" />
<AppPermissionRequest Scope="http://sharepoint/content/sitecollection/web/list" Right="FullControl" />
<AppPermissionRequest Scope="http://sharepoint/content/tenant" Right="FullControl" />
<AppPermissionRequest Scope="http://sharepoint/projectserver/workflow" Right="Elevate" />
</AppPermissionRequests>
Still no progress. I can't open the NewForm.aspx in a model dialog.
UPDATE:
There is something I didn't notice. The List I want to get access to is not provided by the App but by the Site Collection. So I want to access a List outside of the App Scope
NEXT UPDATE:
In a blog I found a post where somebody had to include SP.js, SP.Core.js and SP.UI.Dialog.js into the aspx that called the modal dialog.
At this point I didn't include SP.Core.js and after including it the access denied errors are gone BUT:
I get new errors:
Error in sp.ui.dialog.js
JavaScript runtime error: Unable to get property 'setInnerText' of undefined or null reference
It looks like something isn't initialized at this point.
Second, I've changed my dialog calling function because SharePoint provides one already. Nevertheless with SharePoints function and with my function the errors occur (access denied without sp.core.js and the above one with sp.core.js)
The new calling function is:
function OpenDialog() {
var url = "/Lists/ListName/NewForm.aspx";
var options = { url:url, width: 600, height: 500, showClose: true, allowMaximize: true };
OpenPopUpPageWithDialogOptions(options);
}
I also tried to run the command with ExecuteOrDelayUntilScriptLoaded(func, script) to ensure all background stuff is loaded correctly. Still got the error.
Should I use SP.Core.js and try to get rid of this error? Or is it better to try to get rid of the access denied error without the SP.Core.js? And how would I be able to get the Dialog running?