Site icon @WonderLaura

Query String URLs are Magical (Part 2 of 4)

Advertisements

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.
  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=

    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.
  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.
  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.
  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:
  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.

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:


Exit mobile version