3

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:

Dialog Error

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?

  • Maybe not relevant anymore but try checking in your master pages. That was our issue. – user39157 Jan 29 '15 at 15:58
4

check proper app permissions is given.

<AppPermissionRequests>
  <AppPermissionRequest Scope="http://sharepoint/content/sitecollection" Right="FullControl" />
</AppPermissionRequests>

as well if you are using SharePoint Hosted app, try the following example.

http://code.msdn.microsoft.com/office/SharePoint-2013-Use-list-cb3e4e14

http://social.technet.microsoft.com/Forums/sharepoint/en-US/f8dc50cc-4e8f-498b-940e-849c4b61f555/showing-a-modal-popup-dialog-box-in-parent-window-from-an-app-part

  • I didn't have the sitecollection permissions. But with FullControl it doesn't work, too. I don't really understand the social.technet link stuff. and the msdn code is interesting but I can't figure out what I am missing in my project with this code. Probably it's something simple, yet hard to find. – Loki Jan 7 '14 at 11:47
  • 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 – Loki Jan 7 '14 at 12:41
1

try putting the full URL? by putting "/Lists/xxx", this is assuming that your list is also lies within the same web or same domain.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.