You prepare a summary report on SharePoint 2013 and want to provide a link to open it in a nice modal window instead of taking users to a different page.
Let’s say we’ve got two lists called Projects and Tasks where tasks references projects by means of a lookup column called Project. We want to add a modal report to each project to display related tasks within the next 30 days. These are especially useful on display forms, but can also be used on list views, providing a View Tasks link next to each item.
For this excercise, we will use Calculated Column to create the link for the modal report. We need to filter tasks by Project ID however it is not possible to reference ID field in a Calculated Column directly (it works fine for existing records when you set it up but does not get updated when you add a new record). Because of this we will create a workflow to update a new column, called ID-NUM every time a new project is created.
Here is how you do it:
1. Create a view in Tasks list, called Next 30 Days, filter task due date using [Today]-30.
2. Create a new column in Projects list, called ID-NUM, with a data type of Number.
3. Create a workflow in SharePoint Designer to update ID-NUM with CurrentItem:ID every time a new project is created.
4. Add a new Calculated Column in Projects list and call it Task Report using the following formula:
=”<div><a href=’#’ onclick=””SP.UI.ModalDialog.OpenPopUpPage(‘https://mydomain.sharepoint.com/mysite/Lists/Projects/Next 30 Days.aspx?FilterField1=Project_x003a_ID&FilterValue1=”&[ID-NUM]&”&IsDlg=1’);””>View Tasks</a></div>”
5. Important: Select “Number” as Calculated Column’s data type. This allows column to process HTML tags correctly instead of just displaying them as they are.
And you are done !
Under the hood:
a. We call Next 30 Days.aspx using FilterField1=Project_x003a_ID, which allows us to filter tasks by Project:ID.
b. IsDlg=1 parameter, which can actually be added to any SharePoint form ensures the page is displayed without page header and footer, just as a blank page with whatever content in it. Without this parameter, we would get another set of Suite Bar and Ribbon within the modal window.
c. Finally, SP.UI.ModalDialog.OpenPopUpPage opens the page in a new dialog.
Any questions, please ask.