I dont have access to SharePoint designer :(. My goal is to make a button that says something like "Create new item" and when clicked pulls up the form to create a new item in a list. Is this posible?
2 Answers
By default your "new list" form will open as what is called a modal window (this is how it overlays your list) but is actually a separate page. To make it easy to get the URL of the form, you can:
- Open your list, and in the ribbon select List Settings
- Selected Advanced Settings Scroll to the bottom of the page and find the "dialog" heading and set to no.
- go back to the list and select "new item" and it will open a full page view
- Copy the URL and use that for your link.
Be sure to turn the dialog option back on if you want that when working in the list directly.
-
Thank you this worked! One more question. Is it posible to copy the adress or code for creating a new word document from the ribbon toolbar? For example when i click create new document instead of upload in a document library it goes straight to opening up the template.– steveCommented Jun 28, 2013 at 14:55
-
I'm not sure how you would accomplish this off the top of my head, There is a SharePoint.Opendocument javascript method (from CSOM) that you can probably leverage, but I have not done anything in that scenario. I would go ahead and ask this as a new question and see if anyone has other inputs. Commented Jun 28, 2013 at 15:48
Sounds like you need a custom button that opens a new form dialog. Pop this into a Content Editor. Make sure you click the 'Edit HTML source' in the Content Editor settings:
<script type='text/javascript'>
function OpenNewForm() {
var listName = 'MyListUrl';
var options =
{
url: L_Menu_BaseUrl + "/Lists/" + listName + "/EditForm.aspx?ID=1&IsDlg=1",
dialogReturnValueCallback: Function.createDelegate(null, newFormClosedCallback)
};
SP.UI.ModalDialog.showModalDialog(options);
}
function newFormClosedCallback(result, target) {
if (result === SP.UI.DialogResult.OK) {
SP.UI.Notify.addNotification("List item was added.", false);
}
if (result === SP.UI.DialogResult.cancel) {
SP.UI.Notify.addNotification("Add new item was cancelled.", false);
}
}
</script>
<input value='add a new item' type='button' onclick='OpenNewForm();' id='btnNewForm' />
I added a callback that adds a notification when the form is closed. You can remove that if you want.