Link List Items to Document Set Automatically
-
- Posts: 2
- Joined: Wed Mar 04, 2015
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
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
- Dmitry Kozlov
- Site Admin
- Posts: 1524
- Joined: Thu Jun 07, 2012
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:
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'));
-
- Posts: 2
- Joined: Wed Mar 04, 2015
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.
I have also added fd.field('ParentLookup').value(GetUrlKeyValue('ParentID')); to the new form.
- Dmitry Kozlov
- Site Admin
- Posts: 1524
- Joined: Thu Jun 07, 2012
Hi,
Please, use the following code to insert the link to the new form:
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');
-
- Information
-
Who is online
Users browsing this forum: No registered users and 9 guests