Page 1 of 1

Related Documents question [New form]

Posted: 05 Feb 2020
by thebrightlord
I've read this link but found it unclear on the item I need most: setting the lookup values automatically on a source library [where the related documents live] on an item that isn't created yet, from a new form on a separate list.

I added the related items field onto my New Form, and am able to drop documents into it fine, but how do I go about setting the lookup in the source list when I'm on the New Form and have not saved, in other words, not created an item yet? I attempted to use a workflow to set the lookup in the source but it quickly became boundless (e.g. set the lookup by the matching value found by using the lookup value).

I've gotten this working for Edit/Display, because at that point the edit/display item already has the Title field populated and I can bring up all documents that were attached on that specific item ID. I would like to use the Title if possible on the New form, but am open to suggestions.

Re: Related Documents question [New form]

Posted: 10 Feb 2020
by mnikitina
Hello thebrightlord,

I'm sorry for the delayed reply.

The related documents will be bind automatically once the parent item is saved. Please follow the instructions for the new form from the article:
https://spform.com/documentation/related-documents

Note, that Parent in the below code is the internal name of the lookup field in the document library that points to the parent items list.

Re: Related Documents question [New form]

Posted: 04 Mar 2020
by thebrightlord
Why would you link me back there? I've read it and it doesn't work for the reason I've stated: there's no binding taking place at the time the documents are dropped on New Form, because the lookup in the document library doesn't know what the field values are it should get because the item in the parent list hasn't been saved yet.

Edit/Display works as written, but I have to go in manually each time and drop the documents after the item is already saved to force the lookup to grab the parent list field values.

Are there any examples of people who have used it successfully on New Form?

Re: Related Documents question [New form]

Posted: 04 Mar 2020
by mnikitina
Hello thebrightlord,

If you are uploading files using Related Items control in a New Form, the files will be orphans (not bound to parent item) until the parent item is saved. Once the parent item is saved, files will be bound to the parent with the item ID.
This is how it works in a New Form.


If you want to bind files to parent item as soon as they are uploaded, you need to upload them in an Edit Form. As an option, you can redirect a user from the New From to the Edit Form. You can find the instructions here:

Re: Related Documents question [New form]

Posted: 04 Mar 2020
by thebrightlord
mnikitina wrote:
04 Mar 2020
Hello thebrightlord,

If you are uploading files using Related Items control in a New Form, the files will be orphans (not bound to parent item) until the parent item is saved. Once the parent item is saved, files will be bound to the parent with the item ID.
This is how it works in a New Form.

If you want to bind files to parent item as soon as they are uploaded, you need to upload them in an Edit Form. As an option, you can redirect a user from the New From to the Edit Form. You can find the instructions here:
As it turns out, the JavaScript code in the article does not like the use of the word 'Lookup' as the Parent field, particularly on the New Form. On the Edit/Display it worked fine. I switched to test environment and built a new pair of list&library for purposes of show and tell, and changed the lookup field names. As I was making a GIF to demonstrate what I was doing, the code began to work on the New Form save.

Here is a GIF for anyone who might need a visual illustration of the process:
https://1drv.ms/u/s!AvCWHIBiZGdrg6xnE-pLONYa-iM7LQ