Page 1 of 1

Link List Items to Document Set Automatically

Posted: 04 Mar 2015
by chiptech44
Hello,

I have a Document Library and a List. My thought is to create a new "Documents Set" from the document library using the form and when I select save I am redirected to a different form that creates "List Items" in my List. When I create a "List Item" I want it to automatically link to the "Document Set" I just created. I have explored creating "lookup field" on the List form to point back to the document library but I do not want to select the "Document Set" from a drop down. I want the relationship to be populated automatically based on my last created "Document Set"

Could someone help me with the logic behind this and what I would need to do to make this work?

I appreciate your help,

Erik

Re: Link List Items to Document Set Automatically

Posted: 05 Mar 2015
by Dmitry Kozlov
Hi,

You can customize the Document Set home page (docsethomepage.aspx) by adding Content Editor or Script Editor web parts. Say, you can generate a link to a new form of the related list and add an extra parameter into its URL: ParentID that will contain ID of the current Document Set. You will use this parameter in the new form of the related list to populate the lookup field with the help of JavaScript following way:

Code: Select all

fd.field('ParentLookup').value(GetUrlKeyValue('ParentID'));

Re: Link List Items to Document Set Automatically

Posted: 05 Mar 2015
by chiptech44
Thank you for your reply. I have customized the Document Set home page with a Script Editor web part that has a link to the related list. How do I add an extra parameter into the URL pointing to the "New Form". When I click the link it brings me to the new form but the look up field is not automatically populated.

I have also added fd.field('ParentLookup').value(GetUrlKeyValue('ParentID')); to the new form.

Re: Link List Items to Document Set Automatically

Posted: 09 Mar 2015
by Dmitry Kozlov
Hi,

Please, use the following code to insert the link to the new form:

Code: Select all

<a href="#" onclick="window.location = 'NEW Form URL?ParentID=' + GetUrlKeyValue('ID');