Passing Multiple Query String Variables Using SPD – Follow Up on Creating Parent / Child List Relationships
Guest Author: Mark Rackley
How’s that for a long blog title? Well, by far my most popular blog post has been about creating a Parent / Child relationship in SharePoint Designer and one question keeps getting asked over and over again: “How do I pass multiple values to the new item screen for the Child?” So, I thought it was about time I actually told you how. :) Are you ready?
As stated before, this blog is a direct continuation of a previous blog post Creating a SharePoint List Parent / Child Relationship – Out of the Box. So, if you think you are lost, follow the steps on that blog post first, then come back.
First thing we need to do is break down what we are going to do into its parts and then tackle one at a time. We are going to do the following:
- Make the default Web Part invisible (in case you are modifying your DispForm.aspx file).
- Drop new DataFormWebPart for parent on DispForm.aspx page
- Set up a data connection to create a parameter on the Child Web Part that has the same value as the parameter on the Parent
- Pass this parameter in the Query String to “NewForm.aspx” of the Child
Maybe one of you geniuses out there know how to do this in fewer steps?
Step 1: Make default Web Part Invisible on Parent DispForm.aspx
If you are doing your work in the default DispForm.aspx of the parent (Issue from previous blog) then it is necessary to make the default web part on the page invisible. DO NOT delete the default web part. This will break your list views and you will not be able to get them back.
You actually should not be making the changes to the default DispForm.aspx page, you should create a new Display page and then associate this page as the Display Form for your list. How do you do this? Wow, you ask a lot of questions. Okay.. Quickly:
- Create new display page: File->New->Page->List View Pages
- Right click on your List and select “Properties”
- Click on the “Supporting Files” tab
- Click on the “Browse” button next to the “Display item form” box and point it to your previously created form.


*one caveat* I have had very limited success re-associating forms this way. It is SUPPOSED to work fine. Unfortunately, just because something in SharePoint is supposed to work, doesn’t mean it will.
So, I’m going to assume that you are modifying the default DispForm.aspx and we need to make the default Web Part invisible. We are doing this so we can add a DataFormWebPart for the Parent (Issue) on the page and set up a data connection between the child and parent. This data connection cannot be set up on the default DataFormWebPart.
In order to make the default Web Part Invisible follow these steps:
- Search for the string “<IsVisible>true</IsVisible>” in DispForm.aspx of the Parent (Issue).
- Replace “true” with “false”
- Save the file
How painless was that? View the page now in SharePoint, you will see that there is no data displayed for the parent item. On to our next step.
Step 2. Drop new DataFormWebPart on page for Parent (Issue)
We now need to drop a new DataFormWebPart on the page for the Parent (Issue) Web Part. If you are asking yourself, WHY do I keep putting “(Issue)” after the word “parent”, then you obviously didn’t read my previous post. The parent list in the previous blog was for storing Issues. Got it? Can I stop saying (Issue) now? okay.. thank you.
So, to drop the new DataFormWebPart follow these steps:
- In the DispForm page of your Parent list, place your cursor after the “<asp:Content ContentPlaceHolderId=”PlaceHolderMain” runat=”server”>“ line in the aspx page (this is where we are going to put our new Web Part).
- Click on “Insert->SharePoint Controls->Custom List Form”
- Make sure you have your parent list specified, click the “Display item form” radio button, then click “OK”


You will now see the display form for your parent on the page. You will notice that this display form differs from the default web part. You have a lot more control from here, you can even go in and modify the look and feel of the Display Form using standard html to make it look nicer. Have fun with that, I’m not responsible for what you break.
Step 3. Set up a data connection to create a parameters on the Child Web Part that have values from parent
Okay, so now, let’s get the data from the parent into a parameter that the child can see.
The following steps are necessary to create a parameter on the Child List for the “Status” field in the parent.
- Go to the Common View Data Tasks for the Child List on the Parent DispForm.aspx page
- Click “Web Part Connections”
- Select “Get Parameters Form”
- Make sure “Connect to a Web Part on this page” is selected and click Next
- The Target Web Part should be your Parent List, action should be “Send Row of Data To”. click Next
- Click on “<Create a new parameter>”
- Give the Parameter a name and then click OK (I used “ParentStatus”)
- Select the field in the Parent List to associate with the Parameter name you specified
- Click Next
- Just click Next on the next screen
- Click Finish!








You can repeat steps 6 – 8 to create more parameters if you’d like.


*phew* If you think that too you a while to do, think who long it too ME to capture all the screens and type it in. :) So, still with me? Good! We now have parameters created in our child list that we can pass as Query String variables. On to the next step!!!
Step 4. Pass this parameter in the Query String to “NewForm.aspx” of the Child
We now need to modify the URL used to go to the “NewForm.aspx” page of the child so that it passes the parameter as a query string variable. Just follow these easy steps:
- Go to the link in your code.
- Add the parameter as a Query String variable.
- Save your file.
If you are going off the previous blog, find this line:
<a href="../Time/NewForm.aspx?IssueID={$IssueID}" onclick="javascript:this.href = unescapeProperly(escape(this.href)); GoToLink(this); return false;" target="_self">Create a new Time Log Entry…</a>
Now add “&Status={$ParentStatus}” to the previous line as follows:
<a href="../Time/NewForm.aspx?IssueID={$IssueID}&Status={$ParentStatus}" onclick="javascript:this.href = unescapeProperly(escape(this.href)); GoToLink(this); return false;" target="_self" class="ms-alignleft">Create a new Time Log Entry…</a>
That’s it! Now when you click on the link to create a new child entry it will pass both the ID of the parent and the status of the parent. Just be sure to add JavaScript to the NewForm.aspx of the child to set the status field in much the same was as you did to set the ID field.
So, there you have it. Add as many query string variables as you like. Hope this answers all the previous questions, if not. What did I forget? Again, thanks for reading my blog. Hope you learned something useful.
Guest Author: Mark Rackley
Mark has been developing software applications for over 15 years filling the roles of Project Manager, Business Analyst, Lead Developer, and Software Architect. He has been involved in projects for such companies as Dell, Motorola, Intel and Agilent Technologies. He has worked in large corporate environments, small software start-ups, and as a consultant.
Mark currently works for UNFI where he was introduced to the world of SharePoint and has taken on a lead SharePoint architect role within his organization making key development, administration, and architecture decisions. Mark’s goal is to help ever new architect and developer avoid the frustrations and brick walls he ran into while learning SharePoint.
Blog: http://www.sharepointhillbilly.com
Email: [email protected]
Twitter: http://www.twitter.com/mrackley
- SharePoint Date Filter: Filtering a List by Greater Than or Equal to Date
- Creating a SharePoint List Parent / Child Relationship - Out of the Box
- Passing Multiple Query String Variables Using SPD – Follow Up on Creating Parent / Child List Relationships
- Setting SharePoint Form Fields Using JavaScript
- Tips When Asking For SharePoint Help
- Setting SharePoint Form Fields Using Query String Variables Without Using JavaScript
- Creating a SharePoint List Parent/Child Relationship – VIDEO REMIX
- SharePoint: Populating Drop Down List Field with Data from Different Site
- Building The Right SharePoint Team For Your Organization
So have been using SPD for the last week, trying to do something similar (create a parent purchase requisition with details (child) for each item to order). I am not a hard core programmer but know my way around apps used to build code.
In all my searches I have not found an easy way to pass a parent id to set the relationship for a new child row. This post is as close I can find.
I find it hard to believe it is this difficult, that requires java code (to set the new child form value to the parent id, which btw i cant get to work) to do something that would take a few clicks in access with no coding (see subforms).
This is a common business requirement (creating multiple child rows with a default value equal to the parent id) and there seems to be no material on how to do in SPD or SP UI.
I.e., how do you originally enter data for parent and child rows and keep the relationships (without having to manually type the parent id in the children rows)
Am extremely frustrated, any help appreciated (incl if the answer is – “nope, it is really this hard in SP”).
PS –
“*one caveat* I have had very limited success re-associating forms this way. It is SUPPOSED to work fine. Unfortunately, just because something in SharePoint is supposed to work, doesn’t mean it will.”
A: you have to set the “content type specific forms” drop down list to “item” or else you’ll get a silent fail and it will keep defaulting back. (dont ask me why.)
Hi Mark,
Thanks for your post!
In my site I have two lists, yes, parent and child.
I’m faced with the classical problem of how to send the parent ID to a new child item when creating a new record within the parent.
I’m using SPD 2010 however.
I have tried your steps outlined in the post, but can’t seem to manage.
Once I think I almost got it (I could see I was sending a parameter along to the child NewForm.aspx), but in the URL of the child NewForm.aspx, the URL had changed?! Anyway, the ParentID was no longer in the QueryString ;-(
Is there a standard (non-coding) way on how to do this?
I’m using standard out-of-the-box NewForm.aspx, DispForm.aspx & EditForm.aspx forms for the parent and have placed the child web part on these forms with filter data connections to the parent so that you can see the relations.
I have a feeling there must be an easy out-of-the-box configuration to do this using the new 2010 Designer or maybe even InfoPath.
Hope you can shed some light into the darkness.
Much obliged,
Waldemar