Filtering a Gantt View by Query String

This post applies to all versions of SharePoint and Office 365.

If you ever wanted to filter a datasheet view of a list or a Gantt view via parameter or web part connection, you may have noticed that there is no option to create this type of filter via web part connection, and these types of views cannot be tweaked in SharePoint Designer.

The method I’ve come up with entails creating folders for each of the type of thing that you want to filter by.  For example, if I have a case management site where I want to see a pretty Gantt chart of all of the task items only related to the progress of that one case, my folder structure of tasks needs to be one folder for each case in the case management system.

With that said, this solution may not be applicable in many situations where filters need to be done on-the-fly.

In my case management system, each time a new case is created, which is a single InfoPath form, I have a workflow that runs and creates several items in a task list, which are all of the tasks that need to happen for that case.  Every case gets the same set of tasks.  The workflow creates a folder in the task list, with the name of the case, then the workflow creates several tasks inside that new folder, for all that case’s tasks.

With that said, that’s the structure I’m dealing with.  Basically a task list with a folder for each case, and a need to have a dynamic “dashboard” for each case that shows only that case’s tasks as a Gantt chart.

Steps:

  1. Go into the task list’s List Settings, and go to Advanced Settings. Change Allow management of content types to YES.
    ch5[206]
    Also while on that screen, set Make new folder command available to Yes. (For mine I didn’t have to do this, since I was creating the folders via workflow).  Click OK.
    ch5[208]
  2. Here is my task list.  See that it’s a list of folders.  Inside each folder are the tasks for that case.
    ch5[204]
  3. Create a new view in the task list.  After you click the Create View button, choose Gantt view.
    ch5[205]
  4. Name it whatever you’d like, such as something like “Gantt Tasks”.  Set this as the DEFAULT VIEW, and pick whatever Gantt view fields and settings you need.  It is very important that this is set as the default view.  In the Folders section, choose “In folders of content type” and choose Folder.  Click OK.
    ch5[209]
  5. On the task’s list settings screen, scroll down and click on the name of your view called “All Tasks” (the one that WAS the default view), and scroll down in the view’s settings to the FOLDERS section.  Under Show this view, select In the top-level folder.  (Note that this setting will NOT be in here if you haven’t done step 1 – allow mgmt of content types).  Click OK.
    ch5[207]
  6. On your List Settings screen, your views should look like this:
    ch5[213]
  7. You’ll notice now, that when you click Tasks in the breadcrumb trail to navigate back up to view your list, it will initially show just the names of the folders, but when you click on a folder name, then it will show the Gantt view of the items in that folder.  Now all you need to be able to do is link directly to that filtered list of items for each project’s “dashboard”.
  8. I need the URL, so I click on one of the top level folders and copy the URL.  A variable with the case name will have to be used in here, so that people can click a link to go straight to the dashboard for any project.  Here is the URL:http://www.contoso.com/personal/laura/Lists/Tasks/gantt.aspx?RootFolder=%2Fpersonal%2Flaura%2FLists%2FTasks%2F4443&FolderCTID=0x01200026FFDF69BB12F64096EF8BBB82B5EBA7
  9. See the 4443 in that URL?  THAT is the name of the case folder that I clicked on, so THAT is what needs to be variable per case.  Keep in mind that in this particular project, the original case was a form library of InfoPath forms that had been filled out for each case.  So what I want to do is add a hyperlink to my list of forms for “Details” for that case, which will take me to this filtered view of the tasks in a Gantt view.  Therefore, I’m going to my list of forms, and whatever the Case number is, that is what needs to be placed in that RED part of the URL.
    ch5[214]
  10. I opened up my list of forms in SharePoint designer, and simply added a new empty column to the table and inserted a hyperlink in it:/personal/laura/Lists/Tasks/gantt.aspx?RootFolder=%2Fpersonal%2Flaura%2FLists%2FTasks%2F{$thisNode/@FileLeafRef.Name}&FolderCTID=0x01200026FFDF69BB12F64096EF8BBB82B5EBA7
  11. The name of my InfoPath file name just happens to be equivalent to the name of my case, which is the same name I used for the name of all of the folders in the task list.
    ch5[215]
  12. Once you’re done adding that hyperlink, then save the page.  Now, when I’m looking at all my cases, I can click “details” to see the specific Gantt view of tasks related to that case.
    ch5[218]

Obviously, this is just a small piece of what is a much bigger project.  Hopefully you’ve enjoyed this tidbit.  If you’d like to read more about the concept of query strings in SharePoint, I’ve written a set of 4 blog posts that start here: Query String URLs are like, SO Useful! (Part 1 of 4)

16 comments

  • Laura, Great post! Would you be able to share your Infopath form and workflows as well? I’m new to building solutions in SharePoint and want to utilise out of the box features as much as possible, what you show here sounds really great and something I could use for our internal IT tasks. Oh, is there a typo on steps 8 and 9, just looks like the folder has an four 4’s but your URL contains only three. Keep up the great work

  • Greg, Hi, I blog this stuff whenever I can, and have categories on the left side of my blog, such as infopath and workflows. To learn workflow, I recommend my post called “The best workflow tutorials”. Also, I’m currently writing a book on InfoPath, and the link is on my homepage.

  • M.Aftab Farooqui

    Hello Laura, Great post ! In SharePoint 2010,there is a “Project Tasks List” so I can’t get step 4…….choose “In folders of content type” and choose Folder. pls let me know difference between “Tasks” list and “Project Tasks” list. finally please make a video of this session if possible. Truely wonderful !

  • Aftab, Did set “manage content types” to yes? If so, then you should see that option. As far as I can tell, the difference between tasks and project tasks is mostly the default Gantt view.

  • Hi Laura, How do I create a sharepoint designer workflow to move a list item to a folder of another list or even in the same list but different folder/sub folder? I use the Action Copy item from list to list but this only allows me to move items from list to list, not to a folder/subfolder of the list. Please help! Thanks so much.

  • Sydney, You’d have to do this: 1. Create a custom content type of the type: Folder, like call it “custom folder” or something 2. Add that content type to your list 3. Use the “create list item” action in the workflow, and when add each field, “folder” is one of the fields you can add, which is where you enter the name of the folder where you want that item to end up.

  • Laura, Very nice post! I just ran into one little snag that took me a while to figure out. It may be due to our still being on WSS 3.0 with MOSS (we’re planning to upgrade to 2010 in the 4th quarter). I know this post is old, but I wanted to share this:

    If you get a xsl error “semi colon character expected” when modifying the target, you may need to escape the & after the parameter. I had to substitue & for the one &. My issue was that Sharepoint Designer wouldn’t allow me to change the format of the field to insert the hyperlink, so I added an tag to hold the parameterized link using your general guidance. The parameter is the same field name value as the tag the follows.

    If anyone else was having similar trouble, I thought that might help.

  • Hi Laura,

    Thank you for your nice post! Base on your solution to filter Gantt view, how can I arrange the list, “Cases”, and the Gantt View in to one page? I use web part page to achieve this requirement, but I can’t not pass the URL in the name of “MORE” to another web part. Could you kindly provide some hint to me? Thank you for your kindly support.

  • Bruce, Thanks!

    Lin,
    I don’t know how that could be arranged, which is why I put them on 2 different pages.

  • Hi Laura,
    I currently need to filter the gantt view webpart, however connected filter webparts does not work for this type of view. I also cannot use the [Me] as it gives me CORP\system instead of the user’s login credentials. MSDN forums say that I should change the application pool’s account from the current system account to another, the reason being that all users are running implicitly with corp\system and that is why I am getting this value when using [Me]. I do not want to change anything on the server as everything is working perfectly fine and when i connect a current user filter webpart to a normal list view, it filters fine and displays the direct reports for the manager correctly. So what I am asking is if there is another workaround possible, where I can use a filter value within the gantt view to filter on the current user? Perhaps we can pass the current user filter value to a temporary storage list and then use that to filter the gantt view? We could overwrite the temp list storage everytime a new user value comes into being or take the last value in the temp storage list or we could have a workflow to delete the list value and store the new user value in the field? not sure what my options are here, do let me know what is your opinion
    Thanks much Laura – Reema
    My email is: reema.pereira@catalystpaper.com if you need to reach me.

  • Reema,
    I recommend fixing SharePoint so that it works in the normal way instead of having everyone showing up as corp\system. I do not know of another method to accomplish this solution.

  • Hi Laura,
    Great post, I have got this working fine and the folder is created as part of a custom task list. The folder looks as though it is named correctly, but when I click on it to open it the Folder Name in the breadcrumb is a number like 66_.000
    I assume that this is the ID but I cannot work out the field/column I need to update in the workflow with the name rather than ID.

    Any ideas please?

    Thanks

    Paul (@w0wsers)

  • Sorry Paul, but I can’t seem to replicate that. What version of SP are you using? I originally created this for 2010.

  • Thanks Laura, it’s SharePoint Online.

  • They must have changed the structure of it in that version, I’m sorry.

  • Hi Laura, I’ve used this a couple of times. Works perfectly! what I would also like to do is to apply that same solution to a calendar instead of a Gantt against the same task list however there is no ‘folder’ section when creating a calendar view. Would have a solution for this?

Leave a Reply