Link List Items to Document Set Automatically


Posted by chiptech44 - Mar 4 ’15 at 01:42


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,


  • Dmitry Kozlov
    Dmitry Kozlov
    Member for: 9 years 4 months 17 days
    #1 by Dmitry Kozlov Mar 5 ’15 at 04:10


    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:

  • chiptech44
    Member for: 7 years 11 months 4 days
    #2 by chiptech44 Mar 5 ’15 at 03:40

    [#1]: 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.

  • Dmitry Kozlov
    Dmitry Kozlov
    Member for: 9 years 4 months 17 days
    #3 by Dmitry Kozlov Mar 9 ’15 at 08:11

    [#2]: Hi,

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

    <a href="#" onclick="window.location = 'NEW Form URL?ParentID=' + GetUrlKeyValue('ID'); return false">Link to form</a>
Displaying 1 to 3 of 3 messages