1

I have an item list called "MyPeople". I have a document list called "MyDocs". I associated documents in "MyDocs" to list items in "MyPeople" via Lookup field. On my Site page, I have a LVWP for "MyPeople". The only column in "MyPeople" is a calculated column with a hyperlink. When pressed, I'd like to invoke a pop-up showing a list view of the "MyDocs" document library filtered by the list item. I want this to work for each individual list item. How can I do this? I only need help getting this form/query/filter to exist. I know how to make the calculated column invoking a pop-up box. Thank you!

This has been solved. Working script is below. Thanks again to Venkat Konjeti

<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/1.9.1/jquery.min.js">    
</script> 
<script type="text/javascript">
function openPopup(filterValue) {
alert(filterValue)
var pageUrl = "https://MY-REAL-URL.sharepoint.com/MyDocs/Forms/AllItems.aspx?FilterField1=RelatedPeople&FilterValue1=" + filterValue;  
var options = { url: pageUrl, width: 700, height: 600, title: "My Docs" };
    SP.SOD.execute('sp.ui.dialog.js', 'SP.UI.ModalDialog.showModalDialog', 
options);
    }
</script>
2

Based on your requirements I understand that you have to open a modal window with list documents associated with the person in the MyPerson list. To achieve this you can make following changes.

Change to the calculated column with hyperlink

The link should be formatted as follows

<a href="javascript:openPopup('" + personname + "')">show my docs</a>

Add JavaScript to open Modal Popup

You should following script using script editor web part to the MyPeople list view web part page.

function openPopup(filterValue) {
        var pageUrl = "siteurl/Lists/MyDocs/AllItems.aspx?FilterField1=MyPeopleFieldLookupName&FilterValue1=filterValue";
        var options = { url: pageUrl, width: 700, height: 600, title: "My Docs" };
        SP.SOD.execute('sp.ui.dialog.js', 'SP.UI.ModalDialog.showModalDialog', options);
    }

Let me know if any of assumption is wrong.

  • Thanks for the quick response!! Going to try this out now, and I'll get back to you ASAP. – TheJDScott May 22 '17 at 15:56
  • Just to clarify, personname should be replaced with 'Title' field in my case. The 'Title' field in "MyPeople" List contain the list of names. Documents are then associated with each of these names -- is this correct? =<a href="javascript:openPopup('" + Title + "')">show my docs</a> – TheJDScott May 22 '17 at 16:45
  • Yes. In order to get the filters, you can few steps. Go to "MyDocs" list and filter your lookup column with one value. It will show the filtered results and from the URL you see what it should be. – Venkat Konjeti May 22 '17 at 17:23
  • What if I opted to use Text fields with autocomplete jquery script on them instead of using lookup columns? Would it be the same process? I don't want to use Lookup columns, because they mess things up in Workflows. I think it would be easier to use text fields instead of lookups. Does that make sense? – TheJDScott May 22 '17 at 17:43
  • For instance, this would be the 'RelatedPeople' Text column in the 'MyDocs' library, referencing the 'MyPeople' list items in the autocomplete script. $(document).ready(function () { $().SPServices.SPAutocomplete({ sourceList: "MyPeople", sourceColumn: "Title", columnName: "RelatedPeople", filterType: "Contains", ignoreCase: true, numChars: 0, slideDownSpeed: 'fast' }); }); – TheJDScott May 22 '17 at 17:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.