1

I have a list that opens items in the modal dialog boxes. Now I would like to have a link on another page that will open the dialog for the new item form. Tried a lot of other suggestions here and elsewhere - nothing works so far.

2

So, if I understand correctly, you have a link on some page and you want to open a New Form of some list in the Modal Dialog when user clicks the link, right? You can do that with JavaScript. The code will look similar to that:

function openDialog(listId) {
SP.SOD.executeOrDelayUntilScriptLoaded(function () {
    SP.UI.ModalDialog.showModalDialog({
        url: 'http://yoursite/yourweb/_layouts/15/listform.aspx?PageType=8&ListID={' + listId + '}&IsDlg=1',
        title: 'New Item',
        allowMaximize: false,
        showClose: true,
        width: 500,
        height: 300,
        dialogReturnValueCallback: function(dialogResult, returnValue) {
            SP.UI.ModalDialog.RefreshPage(SP.UI.DialogResult.OK);
        }
    });
}, 'sp.ui.dialog.js');
}

Where listId parameter is an ID of the list where new item should be created. You can assign call this function from your link onclick event handler.

Or you can probably even try to provide the whole code in your href attribute like:

<a href="javascript:..."></a>

But I wouldn't recommend that

0

Add Script Editor web part in a page, add the following code in the Script Editor web part:

 <script type="text/javascript">

 function displayLayover(url) {

 var options = SP.UI.$create_DialogOptions();

 options.url = url;

 options.dialogReturnValueCallback = Function.createDelegate(

 null, null);

 SP.UI.ModalDialog.showModalDialog(options);

 }

 </script>
<a href='javascript:displayLayover("/Lists/list1/NewForm.aspx?IsDlg=1")'>new Item </a>

Note:change list1 to your list.

Reference:

https://blogs.msdn.microsoft.com/how24/2014/09/23/create-a-link-to-display-edit-and-create-new-items-from-a-dialog-layover-in-sharepoint/

  • I saw this reference and tried the solution - but no joy. The dialog opened is blank/empty. – Quasimodo Jan 23 '18 at 16:52

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.