Creating a form to Add List Item and to a Document Library

Hi,  I'm super new to sharepoint , and have what is probably a newbie question.
I have a list and a document library.  The documents are linked to the items in the list. (1 list item may have one or moe documents associated with it).
I need to create a form to add new list items that will at the same time upload documents to the document library.
Do I use infopath for that?
Thanks

Hi,
According to your description, when adding a new item to the current list, you might want to upload the attachments of this item to other Document Library as well.
As a workaround, you can create an Event Receiver to capture the event when there is “An item was added”. In the Event Receiver, we can write C# code to copy the attachments
from a list item to a Document Library.
About how to create a simple Event Receiver in SharePoint 2013:
https://msdn.microsoft.com/en-us/library/ff398052.aspx
Here is the related code I use in this scenario, you can use it as a reference:
using System;
using System.Security.Permissions;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Utilities;
using Microsoft.SharePoint.Workflow;
namespace SharePointProject13.EventReceiver1
/// <summary>
/// List Item Events
/// </summary>
public class EventReceiver1 : SPItemEventReceiver
/// <summary>
/// An item is being updated.
/// </summary>
public override void ItemUpdating(SPItemEventProperties properties)
//base.ItemUpdating(properties);
/// <summary>
/// An item was added.
/// </summary>
public override void ItemAdded(SPItemEventProperties properties)
// base.ItemAdded(properties);
using (SPSite site = new SPSite("http://sp/"))
SPList docDestination = site.RootWeb.Lists["Document"];
SPList lstAttachment = site.RootWeb.Lists["List1"];
SPFolder fldRoot = site.RootWeb.Folders[docDestination.Title];
SPFileCollection flColl = null;
if (properties.ListItem.Attachments != null && properties.ListItem.Attachments.Count > 0)
foreach (String strName in properties.ListItem.Attachments)
flColl = fldRoot.Files;
SPListItem listtem = docDestination.Items.Add();
SPFile FileCopy = properties.ListItem.ParentList.ParentWeb.GetFile(properties.ListItem.Attachments.UrlPrefix + strName);
string destFile = flColl.Folder.Url + "/" + FileCopy.Name;
byte[] fileData = FileCopy.OpenBinary();
SPFile flAdded = flColl.Add(destFile, fileData, site.RootWeb.CurrentUser, site.RootWeb.CurrentUser, Convert.ToDateTime(properties.ListItem[SPBuiltInFieldId.Created]), Convert.ToDateTime(properties.ListItem[SPBuiltInFieldId.Modified]));
SPListItem item = flAdded.Item;
item[SPBuiltInFieldId.Created] = Convert.ToDateTime(properties.ListItem[SPBuiltInFieldId.Created]);
item[SPBuiltInFieldId.Modified] = Convert.ToDateTime(properties.ListItem[SPBuiltInFieldId.Modified]);
flAdded.Item.Update();
How it works in my environment:
Add an item with attachment in List1:
In the Document Library, we can see the uploaded attachment there:
Best regards
Patrick Liang
TechNet Community Support

Similar Messages

  • Error with Provider Hosted App on Edit Form of a list item

    We have an error on the Edit Form of one of our pages.
    We have developed a SharePoint Online Provider Hosted app which replaces the standard edit form of a list item and has some further events behind the save button. Since this is rather new territory for us, we're using a roundabout way of achieving this by
    using a script editor web part to display an iFrame of our app. That way we can pass the Url through to our app and retrieve query strings from them.
    Our issue comes quite intermittently in that we sometimes get a "web page cannot be found" error or sometimes a "resource cannot be found" error, however, when we load another app on the site (from the same app project, but using an app
    part), then go back to the Edit Form, the information in the iFrame suddenly renders.
    Any ideas on what might be causing this issue at all? Ideally, we should be rendering the app to the Edit Form is the proper manner, rather than scripting an iFrame that points to out app in Azure. Would this be the cause of the problem?
    Thanks
    Tom

    Hi thumper, if you have access to InfoPath, you can add the form to a page using the InfoPath web part. Otherwise, use SP Designer with instructions below:
    http://sharepoint.stackexchange.com/questions/70287/display-new-form-of-a-list-in-a-web-part-page
    cameron rautmann

  • Using a newly created Library document to create a list item and attach itself

    I have a workflow that moves a document from one library to another.
    When a document is moved to a certain library I want to create a list item with a link to the document in the list item.  Keep in mind there could be 10 files submitted to the library, so then in my list I would want 10 new list items created for
    each file, with a link to the individual file. or is there a way to attach the document to a newly created list item programmatically?
    is this possible?

    Hi,
    According to your post, my understanding is that you wanted to use a newly created Library document to create a list item and attach itself.
    I recommend to create a workflow assocaited to the second library, and start the workflow automatically when an item is created.
    Then add action as below:
    Best Regards,
    Linda Li
    Linda Li
    TechNet Community Support

  • Requestors end users will not acces a site directly and add list items

    Hi
    i created a  site for IT services  and this site includes some lists for various services
    http://Intranet.com/Units/IT services 
    main site is http://Intranet.com
    and also workflow are configured  for these lists for create new item
    and only 3 type of users will work on these lists
    1)Requestors (Create,View rights)
    2)Contributers (Contribute permissions)
    3)Approvers
    Scenario:
    -- Requestors    will create list items and approvers will Open this list item and  edit list item like
     approve and add a Contribute userid in AssignedTO field
    ---Contribute user also will recieve email and he also Open item and edit ans save this list
    so basically its backend  , data inserted by requestors will  save in lists
    so here i need all  Requestors  end users will not acces IT services site and add list item directly in list.
    is any other option availabe that i will provide a  diffrent front end page for Requestors at root level  site (which is Intranet.com )
    and they will add and view only their data, and  Contributers  also  view and edit all users data.
    adil

    Hi adilahmed,
    You can use two web parts to show the list items for different group.
    In the List view page, add another list view web part, set the first web part list view to filter Created By field with Me, second list with all list items.
    Then set the first web part with audience Requested group, and second web part with audience Contributers group.
    Thanks,
    Qiao Wei
    TechNet Community Support

  • Add list item using anonymous user in public website of shareopint 2013 office 365

    Can any body know the solution to over come of following error while add list item using anonymous user using CSOM in shareopint 2013 office 365 public website.
    I have tried following solution to narrow down the error from "Access permission"
    http://sharepointtaproom.com/2014/08/28/anonymous-api-access-for-office-365-public-sites/#comment-2304

    Try below:
    http://www.codeproject.com/Articles/785099/Publish-a-Form-for-Anonymous-Users-on-a-Public-Sit
    http://blogs.technet.com/b/sharepointdevelopersupport/archive/2013/06/13/how-to-allow-anonymous-users-to-add-items-to-sharepoint-list-using-client-object-model.aspx
    // Allows AddItem operation using anonymous access
    private
    static voidAllowAnonAccess(){
    Console.WriteLine("Enabling Anonymous access....");
    SPWebApplication webApp =
    SPWebApplication.Lookup(new
    Uri(webAppUrl));
                webApp.ClientCallableSettings.AnonymousRestrictedTypes.Remove(typeof(Microsoft.SharePoint.SPList),
    "GetItems");
                webApp.ClientCallableSettings.AnonymousRestrictedTypes.Remove(typeof(Microsoft.SharePoint.SPList),
    "AddItem");
                webApp.Update();
    Console.WriteLine("Enabled Anonymous access!");  
    // Revokes Add/Get Item operation using anonymous access
    private static
    voidRemoveAnonAccess(){
    Console.WriteLine("Disabling Anonymous access....");
    SPWebApplication webApp =
    SPWebApplication.Lookup(new
    Uri(webAppUrl));
                webApp.ClientCallableSettings.AnonymousRestrictedTypes.Add(typeof(Microsoft.SharePoint.SPList),
    "GetItems");
                webApp.ClientCallableSettings.AnonymousRestrictedTypes.Add(typeof(Microsoft.SharePoint.SPList),
    "AddItem");
                webApp.Update();
    Console.WriteLine("Disabled Anonymous access!"); 
    http://www.fiechter.eu/Blog/Post/12/Create-a-survey-for-anonymous-users-on-Office-365
    If this helped you resolve your issue, please mark it Answered

  • Created a Form in Adobe Acrobat XI and save that form as "Standard" PDF

    I created a Form with Adobe Acrobat XI and now I want to add a button for save that form as "Standard" PDF with Java Script or other suitable way. Please help me.
    Thank You.

    Forms are entirely standard. What do you mean by "standard" in this case. Do you mean "not a form, so that the bits filled in are just permanent parts of the PDF like the other stuff"?

  • 10g: Enabled list items and scrollbars look disabled

    Hi,
    Is there any way to change the way list items and scrollbars look in 10g?
    Enabled list items and scrollbars look disabled to me (the list button on the list item and the arrow buttons on the scrollbars are greyed out).
    Visual attributes doesn't seem able to control this.

    Nope you're pretty much stuck with the look and feel of the decoratiosn unless you want to create your own pluggable component - this would give you more control but you'd have to consider if it's worth the investment.

  • Help with select list item and dynamics action

    G'Day Apex Gurus,
    I having problems trying to achieve to trigger the help window of a select item automatically. A help window is triggered when the select item label is clicked but my client would like to be triguered automatically as soon as the user click to see the options in the select list.
    I think that I should be able to do it with dynamic actions but I can not get it to work.
    I know when someone click on the label of the select list item trigger this JavaScript
    javascript:popupFieldHelp('277938589795252851','1545903379570909')
    So I want to trigger the javascript also when the user click of the select list item and pull down the options and for that I think that Dynamic actions is the way to go but I can't get it right.
    This is what I a doing:
    I created a Dynamic option as follow:
    Name : test
    Sequence: 30
    Even: Click
    Selection type: Item(s)
    Item(s): P1_RATING <- a selection list item
    Condtion: - No Condition -
    True Actions
    Sequence: 10
    Action : Execute JavaScript Code
    Fire when event result is :True
    Fire on page load: ticked
    Code: javascript:popupFieldHelp('277938589795252851','1545903379570909')
    I appreciate any one who can tell me what i am doing wrong here or provide a solution to my problem of achieving to trigger the help window of a select item automatically.
    Kind regards
    Carlos

    Hi Carlos,
    I set up a test case in exactly the same way and it worked fine for me. I created a page item called P1_DA_DEMO and added some static select list values then added some help text. The settings I used are below, I suggest you try again but also make sure you have no other Javascript errors on the page. Use a tool like firebug to check.
    Name : Dynamic Action Demo
    Sequence: 10
    Even: Click
    Selection type: Item(s)
    Item(s): P1_DA_DEMO <- a selection list item
    Condtion: - No Condition -
    True Actions
    Sequence: 10
    Action : Execute JavaScript Code
    Fire when event result is :True
    Fire on page load: Not Ticked
    Code: javascript:popupFieldHelp('277938589795252851','1545903379570909')
    Event Scope set a s Bind.
    Thanks
    Paul

  • HT2531 Spotlight lists items and shows preview images.  BUT what about showing the location address of an item in my computer. Especially important if I've put the item in the wrong folder and what to locate it without multi-steps. iMac OS 10.5 was more u

    Spotlight lists items and shows preview images.  BUT what about showing the path/location address of an item in my computer.
    Especially important if I've put the item in the wrong folder and what to locate it without multi-steps. iMac OS X 10.5 was more useful.
    Old OSX Spotlight function automatically displayed path/location within the machine:  e.g. desktop/folder/sub-folder/item.
    Can I make Spotlight show the path?

    Press option-command and the path is displayed at the bottom of the little preview window.  Press command-return and the enclosing folder opens. 

  • Is it possible to add value item and non stock item in one billing?

    Is it possible to add value item and non stock item in one billing?

    Hi,
    Yes,it is possible .Take example of service scenario,where material used in servicing and service charges(labour) can be billed in single invoice.
    Billing document type,Customer and other header data should be same.
    Reward points if useful
    Regards,
    Amrish Purohit

  • Created a form in abobe x pro and reduce to 5.0 or later

    I created a form in adobe x pro and reduce size to 5.0 acrobat or later. Why does my security change "Changing the document" not allowed when I have no security. When i send out the form to be filled out the respondent can't fill it out.

    I do not see any such security setting. you may find the file in the location below
    Form location : http://www.uspto.gov/forms/aia_forms.jsp
    Search for
    Form name : AIA/01

  • Is it possible to submit a list item and at same time query/search the results if parameters are matched.

    Hello,
    Is it possible to submit a list item and at same time query/search the results if parameters are matched.
    Example - user logon to site enter search parameters and hit submit button. Once done parameters gets saved in list and shows search results on page. I have been asked to do this with
    SP designer and InfoPath doesn’t work due items limits.
    Please suggest.
    Thanks,
    Manish
    Manish

    Hi Manish,
    may i ask if you need,
    when user account click the login button, it will be authenticate the user and then it will show search result page?
    may i know how the keyword of words to be put? is it together with the user account box, password and keyword?
    or it will be like, after user authenticate, it will redirect to search page, so that user may use the search page to input the keyword?
    Regards,
    Aries
    Microsoft Online Community Support
    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.

  • How to print out document list items (and with all comments!)

    Hi all,
    I am wondering how to get a good printout of document lists.
    In a web application I have some document list items and the users are adding many comments in it, so that the document list item doenst show all in the initial view, but scroll buttons to navigate up and down.
    I was surprised to read that the standard print functionality doesnt support document items.
    http://help.sap.com/saphelp_nw70ehp1/helpdata/en/43/68ce8391886e47e10000000a422035/content.htm
    How can I print out a list of all document list items with all comments?
    Ist there a workaround?
    thanks in advance for sharing your experiences, br, Michael

    Thanks guys for trying to help me...
    Gabriel, I not wanna do "a lot of trix" to get this out of iCal when it should be solved by iCal (from my point of view).
    Dancing Brook, Yes I hope we will see that in the future. I am convinced that there is many of us out there who want to see that function in iCal, even if they not really missed it yet.
    I have already sent a request to iCal feedback (hope they noted). Maybe they will if we are many doing so...

  • Hide the delete menu item from a specific document library

    I want to hide the Delete  item menu option for a specific document library.Since it is for a specific library I would not like to use customcore.js approach.Please suggest some useful javascript for same.
    I have a custom delete action associated with the menu which performs other function as well so need to hide the OOB delete option from the item  menu of a document library.
    I have already used below javascript in CEWP which I added on the document library page itself(allitems.aspx) but yeild no results:
    <script type="text/javascript">
    var elemTable=document.getElementById('ECBItems');
    if (elemTable !=null) {
         var elemTBody=elemTable.childNodes[0];
    //iterate each table row to find the correct ECB menu item to hide(remove)
       for (var iMenuItem=0; iMenuItem < elemTBody.childNodes.length; iMenuItem++) {
             var elemTR=elemTBody.childNodes[iMenuItem];
             var elemTDTitle=elemTR.childNodes[0];
             var title=GetInnerText(elemTDTitle);
     //here we filter on title, but the table contains more information if need be
            if(title =='Delete') {
                 elemTBody.removeChild(elemTR);
    </script>
    Please suggest which can be kept specific and requires no change in masterpage as same masterpage is used across the site.

    Hi justSP,
    Greetings.
    Hope the below links help you
    http://social.technet.microsoft.com/Forums/office/en-US/9adea3a2-6d08-4c04-ace2-88a704833f1d/how-to-hide-delete-item-from-ecb-menu-for-1-specific-custom-list?forum=sharepointcustomizationlegacy
    http://chakkaradeep.com/index.php/sharepoint-hiding-menu-items-from-the-edit-control-block/
    http://social.technet.microsoft.com/Forums/office/en-US/1b832635-4ae7-4f31-826c-2d6b834ece52/hide-delete-from-ecb-menu-for-a-specific-document-library-in-sharepoint-2010?forum=sharepointcustomizationprevious
    http://social.technet.microsoft.com/Forums/office/en-US/919e01e6-9a7a-4439-b778-28e0dc8bffba/how-to-hide-delete-option-from-ecb-menu-in-document-library-in-sharepoint-2010?forum=sharepointdevelopmentprevious
    Please remember to click 'Mark as Answer' on the answer if it helps you

  • Differences between Publishing sites and publishing enabled document library

    Hi
    what is the main differences between Publishing sites and publishing enabled document library 
    and how to enable publishing for document library?
    adil

    Publishing Sites is an out-of-the-box site template designed to publish web pages and it comes with a pre-built workflow or without (depends on which template you pick). It comes with libraries such as Pages library, Publishing Images, or Site Images.
    It is configured to fully customized the master pages (or add new ones), and page layouts.
    There is no such thing as publishing enabled document library. A document library is not designed to publish web pages. You can have Site Pages library in a team site, but if you are looking to fully brand a site collection, then this is not your answer.
    You will need to use a Publishing Site to fully brand your Internet or Intranet site.
    You can enable the publishing infrastructure on any site that is NOT a publishing site, but this does not turn your provisioned site to a publishing site. It simply turns on publishing features, such as navigation management, master pages/page layouts management,
    publishing workflows, etc....

Maybe you are looking for

  • Can't work out what is wrong with my nano

    The 4th gen Ipod nano isn't recognised by itunes and doesn't turn on, when I try to turn it on it comes up with an hour glass and doesn't do anything else.I have tried reseting it and charging it overnight but I can't work it out. I bought it off eba

  • Query on Message/Output Determination in GR/GI Slip

    Hi, Its regarding Message/Output Determination in Inventory Management: We are using the condition Type "WE03" in our system for Goods Receipt. Currently, Print Parameter for the Output Type "WE03" is maintained as 7(i.e Plant/storage location). Now,

  • Viewing encrypted Files in ISDK based AutoVue Integration.

    Dear All, We have developed an Integration based on Oracle AV ISDK. We have a query from one of our customer as: if he checks in the files which is encrypted can he directly view it in AutoVue Applet  (means does AV server will understand that its en

  • Problems of integrating Matlab functions in Labview

    Hi, Does anyone know how to completely integrate Matlab functions into Labview program without a copy of Matlab in the system when I run the entire program? Initially I used 'Mathscrip' node but I heard that it doesn't support Matlab toolbox.  Thus,

  • GoldenGate Manager Does not start  - Windows 7 64-bit, 11gR1 database

    Hi Experts, I ran into very tricky situation and seeking for clarification and if possible solution for the same, here how it goes: (This is a practice setup for my knowledge and not production) My environement: GGSCI (msheth-work) 18> versions Opera