Sharepoint does not support attachments in document libraries. There is a clean way to obtain something similar?
We have two document libraries: "Main Documents" with some metadata and "Related Documents" with no metadata. How we can upload related documents in the edit-form of a document in Main Document and be assured that the related documents does non appear associated with other documents?
I have an idea about using folders but it requires some tricks. I appreciate every possibile solution, programmatically or not.
3 Answers
How about creating two libraries: 1. Main documents 2. Related documents
On the related documents you create a lookup to the main documents and make that field mandatory. This way the related documents are linked to the main documents. Adding a bit of javascript to the edit form of a document it should be possible to open a new window (or lightbox) where you can upload a related document and have the main document lookup preset with the main document you are in edit mode of.
-
Do you have an example? I didn't found any simple way to preset a field during the upload.– PieroSep 18, 2018 at 12:12
-
Not at hand, but you can get the ID from the parent item (main document) from the url value using tGetUrlKeyValue like this: var itemId = GetUrlKeyValue("ID") Then its just a matter of passing that value to the lookup field :)– Morten KSep 18, 2018 at 12:38
I would suggest to use a document set to handle related documents.
An alternate suggestion would be to use 2 lists. The only issue is that its not trivial to make it work in a single page
-
I've tryed with Document Sets, they are interesting but they are "Folders with metadata" rather than "a main document with many attachments".– PieroSep 19, 2018 at 7:59
I'll give a try to this.
Precondition:
- Create a new folder in the second library every time a document is added to the main library. So that the second library has a separate folder associate to every documenti in the main library.
Solution:
1) Change the edit page of the main library adding a built-in web part mapping to the second library.
2) Link the edit page in this way:
http://examplewebsite/Contracts/Forms/EditForm.aspx?ID=1&RootFolder=%2FRequirements%2Ffolder1