Query String URLs are Magical (Part 2 of 4)

In my last post, I showed you what query string URLs are, and a simple example of what can be done with the MOSS Enterprise Query String URL Filter Web Part.  In this post, I’ll get more into a really cool example of what can be accomplished with query strings, and taking it to the next level.

In this example, we have a site with

  • Project List
  • Tasks
  • Issues
  • Change History
  • Status Reports

The point is that all of these lists have something in common… the project.  The main project list can have multiple items associated with it, from each of the other lists.  We want to display all of these items on the same page in SharePoint.  So, we create a “Project ID” field, which will be used as the common thread.  We’ll start with the built in ID field in the main project list, and in each of the other lists, create a number field called “ProjID”.

I usually use workflows heavily in a solution like this, but this post isn’t really about that part.  For now, I just want to show you how to create the “Project Details” page that shows all of the associated info for any given project, in which all associated lists have one common field.

  1. Create a blank web part page, which will be used as the project details page.  Create a blank ASPX page called ProjectDetails.aspx, and save it somewhere like a library.
  2. A workflow step needs to be created on the main project list, so that each time a new project is created, a special URL is created for that project, for the details page.  So first, in the main project list, create a new hyperlink field, and call it Detail Link.
  3. Open the site in SharePoint Designer.  Create a new workflow, and associate it with the main Project list, so that it runs when a new item is created.
    new workflow
  4. The workflow has no conditions.  For the first action, choose Build Dynamic String.  Click the blue words “dynamic string”.  Type in the URL to the new ProjectDetails.aspx page that you created at step one (this can be a relative URL, if you’d like).  At the end of the aspx, type ?Project=
    build string
    Then click the Add Lookup button, and choose the ID field from the current list.  At the end, it’s important to put the comma space “Project Details”, exactly like in the screenshot above.So, WHY are we doing all this?  What does it mean?  Well, this is the bread and butter of how your query string URL works.  In my previous post, I explained query strings.  We’re going to create a “query” called Project, and we’re going to use the ID as the unique identifier for the project.  This is going to be the same number that is tied back to all those other lists related to this project, that will exist as the ProjID.  The word “Project” above in the URL.. we’re just making it up for now (it doesn’t come from anywhere else at this point, and isn’t yet related to any fields or anything we’ve done so far).  The reason for the comma space and Project Details, is that this is how you form the hyperlink, so that Project Details will be the actual words that users click on to get to that detail page.
  5. Name this variable ProjDetailURL (instead of the default word “variable”)
  6. The next action of the workflow is Set Field in Current Item.  Click the blue word “field”, and select the Detail Link field that you created at step two.
  7. In the blue “value” box, click the little function button, and select Workflow Data as the source, and pick the ProjDetailURL variable that you created at step five.CropperCapture[119]
  8. Click Finish to complete the workflow.
  9. In the browser, go to the ProjectDetails.aspx page, so you can start populating it with web parts.  In Edit Mode, click to add a web part, and add all of the associated lists, which in this example would be all of those bullet points at the beginning.
  10. Also add the Query String URL Filter web part to the top of the page.
  11. Edit the views of each of the list web parts on the page, and add the ProjID field to the current view for each.
  12. Go to the web part properties of the Query String URL filter web part.  For the Query String Parameter Name, type “Project”, like this screenshot below.  This word “Project” ties back to step four.  Use the same word here that you used there.  Click OK in the web part tool pane.
    CropperCapture[120]
  13. Time to create all of the web part connections from the Query String URL, to each of the other web parts on the page.  We’ll start with the Project List.
    With the page in edit mode, click the Edit button at the top right corner of the Query String (URL) Filter Web Part.
  14. Click Connections –> Send Filter Values To –> Project List.  Choose the ID field, and click Finish.
    config connection
  15. On the Query String filter web part again, click Connections –> Send Filter Values To –> Tasks.  Choose ProjID as the consumer field name, and click Finish. (This is why we did step eleven.  If the field is not showing in the view, you can’t create a connection to it.
  16. Repeat step fifteen, creating connections from the Query String URL filter web part to every single other web part on the page.  After all the connections have been created, the web part will look like this:
    connections
  17. Then Exit Edit Mode.  All done!

Time to try it out.  Put a query string in the URL, and you’ll see that it will automatically filter all the web parts by that one project ID.  Notice the browser URL, the fact that the Query String URL filter web part is hidden, and that all of the web parts show the filter symbol in the appropriate column. Click the picture below to zoom in.
Project Details Result

To finish it out, try creating a new Project in the main project list, the one we associated the workflow with in step three.  Check out the resulting URL that the workflow creates, and you’ll see that it takes you to the project details page for that project.

Yes, I agree that displaying the ProjID on all of those web parts is quite redundant.  You can make any or all of those web parts as Data View Web Parts, and you don’t have to display the ProjID as a column.  It will then let you create connections to the web parts using any fields in the list, not just displayed ones.

Obviously this is not a complete solution, but a piece of a puzzle.  The rest of the solution would entail workflows that automatically create tasks at certain phases of the project, and form pages that let you click to create a new issue or status report for that project.  Maybe this series of blog posts will be more than four parts.  😉

Here’s my associated video:
MOSS Enterprise – Query String URL Filter Web Parts – Ramping It Up (Video)

Here are the other parts to this series:

19 comments

  • Laura, Definitelly wish you can expand it beyond 4 posts! Was wonderring if there would be a way to have 2 or more query parameters? Greg

  • jvargas.inbox@gmail.com

    Laura, thanks for the guidance, I was just today looking for something similar to visually show a tasks lists and related documents in a doclib where i am doing a lookup to the ID field of the task. All in one page with a couple of unrelated webparts that are informational. This is a great start you have given me. My only challenge is showing documents in the doclib for the tasks based on the view ( active tasks ) of the webpart for the tasks instead of a specific task or project like in your example. I am still green so all guidance will be greatly appreciated. Your posts are now required reading for me in my sharepoint education.

  • jaguzman@ra.org

    Can this be done in SharePoint Foundation?

  • jaguzman, Yes, read post number 3 in this series, all the web parts would have to be DVWPs. jvargas, I don’t understand the question, but maybe you can just connect two web parts together using regular ol’ web part connections.

  • The post turn out to be so useful. Thank you!

  • Hi Laura, I´m a begginer working with sharepoint 2010 … So, I´m having dificult to follow your posts because it´s for moss. Do you have this guide for sharepoint 2010 ?

  • I am working in wss 3.0. I am not able to use any designer software. Can I accomplish this using the “out of the box” wss 3.0? If so, how do I do this? Thanks

  • Cristina, Maybe one of these days I’ll have time to re-write all my 2007 blog posts to update them to 2010. Garrelam, Yes, read part 3 of 4: http://wonderlaura.com/2010/6/12/the-query-string-url-data-view-web-parts-part-3-of-4

  • the post very useful,thanks

  • This is great but when I do this in Sharepoint 2010, in my “detail Link” column, I get the entire URL instead of just the the words “Project Details” which causes the lenght of column to expand is not pretty for users.

    Many Thanks

  • Hi Greg,
    At step 4, be sure to put a space after the comma. That makes a big difference, and has messed me up a few times.

  • Marcus Kanagasuntherie

    Hi Laura
    Thanks for all the great tips..
    any chance you can provide guidance on this for sharepoint designer 2013.
    the build dynamic string doesn’t exist anymore…
    Let me know @marckr32

    Marcus

  • Marcus,
    Build dynamic string doesn’t exist anymore after SPD 2007 because they made it much more efficient after that. Click the little ellipsis button in SPD to pull up the string builder. […]

  • (Child list and parent list )

    Hello Laura,

    I hope you doing good,

    I am looking to use your method, to make one row only appear from a child list site (project status report)on a specific parent site list( projecs status),

    But i want this workflow to apply automatically every time i create a child site using a site template.

    Is this possible ?

    Kind regards
    Magdy

  • Hi Magdy,
    It is possible to create a workflow that creates a site, but I’m not sure if there’s a way to do one that gets triggered when a site gets created. You may want to look at these power hours we’ve done on the topic: https://www.youtube.com/watch?v=nxU8PiuwQTM
    and https://www.youtube.com/watch?v=jtJarTyA_Cg

  • Hi laura ,
    Is it possible to create a web part which is connected by query base url filter aucutully my requirement is i call a filtered list in a single which i had done sucussefully by the help of your post but i want a left navagaion which is custom and related to all filter list and if we click one link like employee details the all list hide and only show the details of employee you mean it what i want to say there are 4 links which relate to the main filter list and shows data individual fields kindly help me

  • Lawee,
    Have you tried using Metadata navigation (sp2010 or 2013 enterprise)?
    Also, this requirement sounds like a search center experience. Have you tried creating a search center site and customizing it?

    Laura

  • Hi Laura,

    I got everything to work perfectly in Sharepoint 2010.

    I have “Project Tasks” & “Project Notes”

    My question is, when I click “Add New Item” Under Tasks or Notes – how do automatically fill in the Project ID of the new item while under that project’s page?

Leave a Reply