Hot answers tagged

12

Document Set is an option. I had also used LinkToDocument as it can link to master document. You can also create a unique column (or field) so these can grouped together.


8

What you are doing is something like this: ItemUpdating (attachItem.Update()) [internal]SPListItem.Update() Which causes the internal Update to fail because you have already done it. Try putting your code in ItemUpdated, rather than ItemUpdating. The flow is then ItemUpdating [internal]SPListItem.Update() ItemUpdated (attachItem.Update())


7

It's not weird, it's by design. Attachments limit size is (if I remember correctly) also limited by the <httpRuntime maxRequestLength="size"/> element in web.config. Check that.


7

How to retrieve attachment files using SPServices function getAttachmentFiles(listName,listItemId,complete) { $().SPServices({ operation: "GetAttachmentCollection", async: false, listName: listName, ID: listItemId, completefunc: function(xData, Status) { var attachmentFileUrls = []; ...


6

You can map a drive to the List: http://community.office365.com/en-us/forums/154/t/5216.aspx The attachments will be under the Attachments folder.


5

Wouldn't you just post a link to the item instead of attach it. I don't know all your requirements, but it seems that that would be a better solution, not only because it is supported OOB, but because it limits overhead with multiple instances of the same file existing in multiple places.


5

Got it worked !! Used an anchor control with Image instead of Image Button!! <a href="" runat="server" id="aAttachmentURL11" target="_blank"> <img src="~/_layouts/images/ipw/PowerPoint-64.png" alt="" style="border: 0px" width="63px" /> </a> Code : And then called the method getlist(string Title) to return the ...


5

Using SharePoint 2010 JSOM i would suggest the following approach to retrieve list item attachments: determine whether List Item contains attachments or not via ListItem.Attachments property in case if list List Item contains attachments, submit a second request to retrieve attachment files Example function ...


4

I had the same problem before. The thing is that sharepoint creates the folder when you add your first attachment, not on creating the item. In other words, the folder you are trying to upload to does not exist. You can create this folder by either adding a dummy-file and removing it in an ItemAdding EventReceiver when you create the item. Another ...


4

You can use DisableAttachments="TRUE" on the top of Schema.xml and you should be good to go: For e.g. <List Title="Test List" Description="Test desc" Direction="0" BaseType="0" Url="Lists/TestList" DisableAttachments="TRUE" FolderCreation="FALSE" Version="8" Type="100" xmlns="http://schemas.microsoft.com/sharepoint/">


4

Okay, so after some debugging I found the problem and, even better, the solution. The OK button on the attach form runs a script called OKAttach(), which features a line towards the end that reads: document.getElementById("idAttachmentsRow").style.display=""; All well and good, except that at some point SharePoint sneaked behind your back and did this to ...


4

I think this forum post on MSDN might be of some help: Add attachment column to copy of NewForm.aspx in sharepoint designer For your scenario, I think you can try to create a custom list form (create custom list form), and then you can use SharePoint control “Form Action Button” instead of the default “Ok” button in the custom list form: ...


4

You can construct the attachment URL by using the SPAttachmentCollection.UrlPrefix property of the attachments collection. For example: string attachmentUrl = item.Attachments.UrlPrefix + item.Attachments[0];


3

If you don't want to go down the document set approach, you could create a lookup column to either a Supporting Files document library or the current document library itself that allows for multiple selections. This would allow you to add additional related documents to the metadata for the "Main" document.


3

I had a glance in the AttachmentsField.UpdateFieldValueInItem call to see where it gets the list of files from for its own use. It appears to use this property: AttachmentsField.Context.Request.Files, the documentation for which is here: HttpRequest.Files Edit: I suddenly realised that you may be trying to access the control in order to save the ...


3

I know this is an old thread, but there are free codeplex solutions that will do what you are asking. http://SharePointStuff.Codeplex.com adds a new activity to SharePoint Designer that allows you to send an email with an attachment. If used on a list item it will send any documents attached to the item or if used on a document library it will send the ...


3

Just a side note. <httpRuntime maxRequestLength="" /> does not work for IIS 7. It has a new setting under system.webServer. See this blog for a reference: http://weblogs.asp.net/jeffwids/archive/2009/09/24/from-iis6-maxrequestlength-to-iis7-maxallowedcontentlengthfile-specifying-maximum-file-upload-size.aspx


3

Most probably the error File not found occurs since you are trying to retrieve attachments folder that not yet exist in method HasListItemAttachment The following example demonstrates how to upload attachment file via SharePoint JSOM: function processUpload(fileInput, listTitle, itemId,success,error) { var reader = new FileReader(); reader.onload = ...


3

Use below REST API example url: "<app web url>/_api/SP.AppContextSite(@target)/web /getfilebyserverrelativeurl('/Shared Documents/filename.docx')/Length For more info: MSDN


3

You can add this script: <script type="text/javascript" language="javascript"> function PreSaveAction() { var elm = document.getElementById("idAttachmentsTable"); if (elm == null || elm.rows.length == 0) { document.getElementById("idAttachmentsRow").style.display='none'; alert("Please attach Documents"); return ...


3

Use SP.ListItem.attachmentFiles to retrieve the collection of attachments that are associated with the list item. How to retrieve list items with attachments using JSOM function getListItems(listTitle,success,error) { var ctx = SP.ClientContext.get_current(); var web = ctx.get_web(); var list = web.get_lists().getByTitle(listTitle); var items ...


3

One drawback that SharePoint lists have is that attachments are not versioned along with other changes to a list item when list versioning is enabled. If you want, you can create custom application for it.We need to attach receivers to the ItemAdding, ItemUpdating, ItemAttachmentAdding and ItemAttachmentDeleting methods. These will be used to push the ...


3

Since you don't need to use the SPServices library, you can accomplish this via REST and the moveTo() method. The following should work: var url = "/_api/Web/Lists/getByTitle('My List Name')/Items", qs = "?$filter=Attachments eq 1&$select=ID,Author/Title,*&$expand=Author"; $.ajax( { url : siteUrl + url + qs, type : 'GET', headers : { ...


3

You are getting this error since attachments are not included via query (view fields). Attachments column is not the same as AttachmentFiles property, first one only returns status whether attachments are included or not, while the second returns attachments info. Since your goal is to retrieve a specific set of fields plus attachments included, you could ...


2

Try working with this code snippet. This assumes you have an SPWeb and SPList open: var item = list.GetItemById("your_item_ID"); var file = web.GetFile("URL_of_your_file"); var bin = file.OpenBinary(); item.Attachments.Add("Attachment Title", bin); item.Update(); Merry Christmas :)


2

Just change below things in your code. //Change requestURI var requestUri = "{Your Web URL}/_api/Web/Lists/getbytitle('Marketplace')/items?$expand=AttachmentFiles"; //Add below line inside loop of results var picUrl = item.AttachmentFiles.results[0].ServerRelativeUrl; and you will have "ServerRelativeURL" of item attachment in "picURL" variable.


2

Improving the code suggested by @wjervis, you can change the header of ajax request to: headers: {          'accept': 'application/json;odata=verbose'      } This way it will return a Json response, that I think it is more easy to handle. You can get the length of the response by doing: data.d.results.length Additionally, you can put one more "expand" ...


2

SharePoint send the alerts when item's properties got change, But when change is made on the attachment, then even list created new version but for some reason alert logic not recognized it. In this case, i believe you have to use some king of custom workflow. check this. Send Attachment in Alert or 3rd party options ...


2

First of all, SP.ListItem.attachmentFiles property is not available in SharePoint 2010. The following REST query returns all attachments in a List in SharePoint 2010: http://<sitecollection>/<site>/_vti_bin/ListData.svc/Requests?$select=Attachments&$expand=Attachments


2

JSOM var listTitle = 'Tasks' var itemId = 1; var fileName = 'Instruction.docx'; var ctx = SP.ClientContext.get_current(); var list = ctx.get_web().get_lists().getByTitle(listTitle); var item = list.getItemById(itemId); var attachmentFile = item.get_attachmentFiles().getByFileName(fileName); attachmentFile.deleteObject(); ctx.executeQueryAsync( ...



Only top voted, non community-wiki answers of a minimum length are eligible