0

I am calling below function 'Dialog' on button click from an app part on a sharepoint page but getting access denied error may be due to iframe's DOM access restriction. Is there any way around or another approach for opening a sharepoint page from an app part. function Dialog() {

hostweburl =
     decodeURIComponent(
         getQueryStringParameter('SPHostUrl')
 );
appweburl =
    decodeURIComponent(
        getQueryStringParameter('SPAppWebUrl')
 );
//alert(hostweburl);
//alert(appweburl);
var scriptbase = hostweburl + '/_layouts/15/';

$.getScript(scriptbase + 'SP.Runtime.js',
    function () {
        $.getScript(scriptbase + 'SP.js',
            function () { $.getScript(scriptbase + 'SP.RequestExecutor.js', ShowServerInformation); }
        );
    }
);

}

function ShowServerInformation() {

var options = {
    url:  "/_layouts/Viewlsts.aspx&IsDlg=1",
    tite: 'Server Information',
    allowMaximize: false,
    showClose: true,
    width: 430,
    height: 230
};
parent.SP.SOD.execute('sp.ui.dialog.js', 'SP.UI.ModalDialog.showModalDialog', options);
return false;

}

AnkitG
  • 46
  • 4

1 Answers1

0

Try and give the app the appropiate app permissions.

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

More info here: http://msdn.microsoft.com/en-us/library/office/fp142383.aspx

Ola Ekdahl
  • 1,484
  • 1
  • 11
  • 21