How to open New List Item Form in modal dialog in a SharePoint 2010 page from different site collection

25,031

P.S. Most safe way to address New form is to use ListForm.aspx page, as follows:

 /_layouts/listform.aspx?PageType=8&ListId={PUT-LIST-GUID-HERE}

(PageType value goes from PAGETYPE enumeration)

i think you should be work when use PAGE_NEWFORMDIALOG : New form for a file dialog box.Value=9 as describe on msdn. if New form is not open on model pop up than

Try this :

HyperLink

 <a href='javascript:;' onclick='Opendialog()'>New Item</a>

Opendialog is Javascript Function

   function Opendialog() {
       var options = SP.UI.$create_DialogOptions();
       options.resizable = 1;
       options.scroll = 1;
       options.url = SiteURLWhichExistList + "/_layouts/listform.aspx?PageType=8&ListId={PUT-LIST-GUID-HERE}";
       options.dialogReturnValueCallback = Function.createDelegate(null, CloseCallback);
       SP.UI.ModalDialog.showModalDialog(options);
   } 

Note : SiteURLWhichExistList pass your site collection url in where your list exist.

Hope it helps!!

Share:
25,031
Eedoh
Author by

Eedoh

Updated on August 01, 2022

Comments

  • Eedoh
    Eedoh almost 2 years

    I need to open a new list item form on hyperlink, or button click, in a Sharepoint 2010 page. The page and the list are in different site collections. I must do this from the Sharepoint Designer, or directly editing the page in a browser, Visual studio project is not possible/allowed...

    Can this be done, and how?

  • Eedoh
    Eedoh over 11 years
    I've done something very similar to this, but I'm still having one more problem. As a form (the one I'm showing in a popup) is on another site collection, after I submit data, it does not close automatically. Instead I'm getting javascript error "Access is denied". Do you have any idea how to get around this?
  • Alan M
    Alan M over 10 years
    In most cases, you can use _spPageContextInfo.webServerRelativeUrl for that "SiteURLWhichExistList" replace-me-with-your-value var in your example. Btw, your example worked fabulous for me, thanks. I +1'd it.