I was asked by a client recently if there was a way to create a hyperlink to a New Item Form anywhere within a site but still get the rich experience of the Modal pop-up window that grays out the background. (Note this is for SharePoint 2010 Only…)
I basically took the code directly from the “Add new item” and the “Add Document” link within the list view.
What this allows you to do is simply add in the following code to any content editor web part, Master page, or Page Layout in any site collection and display the form to be filled out. The user will get the nice experience of the modal window and not have to navigate away from their current page.
This could be used for example a feedback form that is included in the master page so whenever someone wants to give feedback it is always going back to a central list. The only that is required for you to know is the List ID and the site name.
Full Code For a List Item:
<a onclick="javascript:NewItem2(event, "http://SiteName/_layouts/listform.aspx?PageType=8&ListId={83747BB4-49C6-4181-B4A3-F8C6B611846D}&RootFolder=");
javascript:return false;"
href="/_layouts/listform.aspx?PageType=8&ListId={83747BB4-49C6-4181-B4A3-F8C6B611846D}&RootFolder="
target="_self">
Submit Feedback</a>
Full Code for a Library Item:
<a href="http://SiteName/_layouts/Upload.aspx?List={94AC86A8-6774-4822-A197-A98542251678}&
RootFolder=" onclick="javascript:NewItem2(event, "http://SiteName/_layouts/Upload.aspx?List={94AC86A8-6774-4822-A197-A98542251678}&RootFolder=");
javascript:return false;"
target="_self">
Upload a Document</a>
What you need to change:
URL: Change “SiteName” to your URL
List ID: Change the list ID to your custom list/library ID
- To find out the list/library ID, simply navigate to the list/library you want to display and then click on list settings
- Look at the end of the URL.
- You will get something similar to this:
%7B94AC86A8%2D6774%2D4822%2DA197%2DA98542251678%7D - Remove the first %7B and the last %7D
- Then change all %2D’s to “-“
- So the final would be 94AC86A8-6774-4822-A197-A98542251678
You could also add in an image right within the <a> tag and make a nice button for users to click on. Once you have customized the code you can now simply add the code to any page on the site and you will get the following results:
Site Collection 2 hyper linking to a list on Site Collection 1
Comments
What if your list has different content types, each having their own form? Is there a way to make this pop-up specific to the form of a certain content type?
I have the following code that opens an announcement item but I can not figure out how to make it open in a dialog modal. Any thoughts?
a href=\"", web.Url, "/Lists/", this.Text, "/DispForm.aspx?ID=", item.ID, "\"
Thanks,
Rene
thanks in advance...
Thanks
Kandasamy
javascript:SP.UI.ModalDialog.showModalDialog({ url: 'http://wd0931/comms/test/Lists/Albert%20Hall%20Submission/newForm.aspx'
but when you submit the form, the modal pop up goes blank and stays there.
You have to remember that the Sub Folder within the document library is back at Http://yoursite/Shared%20Documnets/Subfoldername
If you look at the ?RootFolder ... you will find %2fShared%20Documents%2fSubfoldername&FolderCTID=#####
the %2f is / and %20 is a space
Hope this helps
Frustrating...
Req:
I have assigned a task to user,and user has to click on the title in task list and it opening in edit format i want that page in popup window in 2007.
Has any one had this issue before?? Can anyone provide feedback on this?
I am creating a page for Frequently Asked Questions (FAQ). I do not want user needs to scroll down for reading each and everything. I want to provide hyperlinks to the text. If the person clicks on a question one popup window needs to appear with text. Is it possible for me to do it in sharepoint 2010. if yes please guide me.
Thanx