Geeks With Blogs

News





The SharePoint Hillbilly Fewer Big Words... More Pretty Pictures...

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:

  1. 1) Make the default Web Part invisible (in case you are modifying your DispForm.aspx file).
  2. 2) Drop new DataFormWebPart for parent on DispForm.aspx page
  3. 3) 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
  4. 4) Pass this parameter in the Query String to “NewForm.aspx” of the Child
  5. 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:

    1. 1) Create new display page:  File->New->Page->List View Pages 
    2. 2) Right click on your List and select “Properties”
    3. image
    4. 3) Click on the “Supporting Files” tab
    5. image
    6. 4) 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:

    1. 1) Search for the string “true” in DispForm.aspx of the Parent (Issue).
    2. 2) Replace “true” with “false”
    3. 3) 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:

    1. 1) In the DispForm page of your Parent list, place your cursor after the ““ line in the aspx page (this is where we are going to put our new Web Part).
    2. 2) Click on “Insert->SharePoint Controls->Custom List Form”
    3. image
    4. 3) Make sure you have your parent list specified, click the “Display item form” radio button, then click “OK”
    5. image

    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.

    1. 1) Go to the Common View Data Tasks for the Child List on the Parent DispForm.aspx page
    2. image
    3. 2) Click “Web Part Connections”
    4. image
    5. 3) Select “Get Parameters Form”
    6. image
    7. 4) Make sure “Connect to a Web Part on this page” is selected and click Nextimage
    8. 5) The Target Web Part should be your Parent List, action should be “Send Row of Data To”.  click Next
    9. image
    10. 6) Click on “
    11. image
    12. 7) Give the Parameter a name and then click OK (I used “ParentStatus”)
    13. image
    14. 8) Select the field in the Parent List to associate with the Parameter name you specified
    15. image 
    16. You can repeat steps 6 – 8 to create more parameters if you’d like.
    17. 9) Click Next
    18. 10) Just click Next on the next screen
    19. image
    20. 11) Click Finish!
    21. image

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

    1. 1) Go to the link in your code.
    2. If you are going off the previous blog, find this line:
    3. Create a new Time Log Entry...
    4. 2) Add the parameter as a Query String variable.
    5. Now add &Status={$ParentStatus}” to the previous line as follows:
    6. Create a new Time Log Entry...
    7. 3) Save your file.

    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.

    Posted on Friday, May 15, 2009 4:50 PM | Back to top


    Comments on this post: Passing Multiple Query String Variables Using SPD – Follow Up on Creating Parent / Child List Relationships

    # re: Passing Multiple Query String Variables Using SPD – Follow Up on Creating Parent / Child List Relationships
    Requesting Gravatar...
    Perfect timing. Thanks!
    Left by Rebecca on May 28, 2009 1:02 PM

    # re: Passing Multiple Query String Variables Using SPD – Follow Up on Creating Parent / Child List Relationships
    Requesting Gravatar...
    When I am clicking on webpart connections->Get to Parameters from..I am not able to select get parameters from webpart on this page. I followed ur previous post and that worked fine but now I wants to pass multiple parameters and its not allowing me....

    help me!!

    Thanks...
    Left by Prakash on Aug 09, 2009 11:23 AM

    # re: Passing Multiple Query String Variables Using SPD – Follow Up on Creating Parent / Child List Relationships
    Requesting Gravatar...
    I am able to pass the parameters but what I am not getting is about the javascript that we need to put on the newform.aspx.

    for everynew parameter I am passing I have to copy that whole javascript u have discussed earlier into newform.aspx? or just some part of it...

    Waiting for your reply...
    Left by Prakash on Aug 09, 2009 12:23 PM

    # re: Passing Multiple Query String Variables Using SPD – Follow Up on Creating Parent / Child List Relationships
    Requesting Gravatar...
    I've used your example and it works great except i'm trying to add a button on the "time/child" form to give th euser the ability to add additional entries. Th eissue im having is that when i click the button it doesnt pull the "parent id". It will on th efirst click, just not the ones after that. Hope this makes sense. any ideas?
    Left by Dave on Nov 19, 2009 11:44 AM

    # re: Passing Multiple Query String Variables Using SPD – Follow Up on Creating Parent / Child List Relationships
    Requesting Gravatar...
    I was looking at this, but is it possible to capture a value of a list (order number) and pass that value to a new form so the person doesn't have to type the order number in again.
    Left by ERic on Jan 19, 2010 12:18 PM

    # re: Passing Multiple Query String Variables Using SPD – Follow Up on Creating Parent / Child List Relationships
    Requesting Gravatar...
    Great article!
    I have a question.
    I'm trying to ad a link to add a new entry to a document library not a list.
    Adding a document is a two step process including two forms. How can I pass a value to the second form?
    Left by Jonas on Feb 01, 2010 2:06 AM

    # re: Passing Multiple Query String Variables Using SPD – Follow Up on Creating Parent / Child List Relationships
    Requesting Gravatar...
    cheers for the post
    Left by buy playstation on Feb 03, 2010 1:04 PM

    # re: Passing Multiple Query String Variables Using SPD – Follow Up on Creating Parent / Child List Relationships
    Requesting Gravatar...
    This was incredibly helpful! I did not know you could pull parameters from another list just by including it (hidden) on the newform page! I wish I would have found this thread a week ago when I was trying to use workflows to update my list after the fact. This works much easier and quicker!! Thanks!!
    Left by Suzanne on Feb 26, 2010 3:31 PM

    # re: Passing Multiple Query String Variables Using SPD – Follow Up on Creating Parent / Child List Relationships
    Requesting Gravatar...
    Great blog (as was the predecessor to this one) and everything worked fine when I created your exact example. When I tried to create the web part connection in my real-world example the "Create a hyperlink on" dropdown is blank! So of course it won't let me finish creating the connection. I've tried every sort of tweak I could think of to no avail. Does anyone know of any obvious thing that I'm missing? Or any insight?

    TIA
    Left by Erin on Apr 06, 2010 12:38 PM

    # re: Passing Multiple Query String Variables Using SPD – Follow Up on Creating Parent / Child List Relationships
    Requesting Gravatar...
    I have a question. I wanted to create a button in a dispform.aspx page. What is does is, it attach the current Item url to outlook. The point is on a button click to open up outlook and attach the url of the item and email it ot receipent. How is this accomplished? I am able to open outlook and populate presubject and body info. using javascript. I stuck on passing the ID of the List item. Would you guide me how to accomplish this? Than you!
    Left by Addis abebayehu on Apr 30, 2010 1:27 PM

    # re: Passing Multiple Query String Variables Using SPD – Follow Up on Creating Parent / Child List Relationships
    Requesting Gravatar...
    Very nice and useful article. Got benefited.
    thanks a ton...

    Thanks
    Uma Narayanan
    Left by Uma Narayanan on Jun 23, 2010 6:20 AM

    # re: Passing Multiple Query String Variables Using SPD – Follow Up on Creating Parent / Child List Relationships
    Requesting Gravatar...
    Hi,
    I a working in SP 2010 and using the relationship method by "Insert Related List" method.
    Here when we add a new child page from the link in the page,It does not default to the parent item .
    Any idead jpw I can accomplish this?
    Thanks a lot
    Left by Priyanka on Jul 29, 2010 8:53 AM

    # re: Passing Multiple Query String Variables Using SPD – Follow Up on Creating Parent / Child List Relationships
    Requesting Gravatar...
    Hi,

    Thanks alot for this valueble resource. I'm new to javascript. Could you please tell me where to add the "Status" related to code in our Javascript ?

    Thanks,
    Rao.
    Left by Venkateswara Rao on Aug 31, 2010 6:12 AM

    # re: Passing Multiple Query String Variables Using SPD – Follow Up on Creating Parent / Child List Relationships
    Requesting Gravatar...
    i could follow this and previous post and it works great. i pass 1, then 2 variable, all fine. But then i wanted to pass the "company Name" as a variable (No3) and when i do it passes all ok to newitem form, but on save it says: you are trying to write to a cell that is maybe read only status. Although if i do not "pass" the variable upfront, but fill in the field manually, the child new item form posts fine and no error appear. Any clues ?
    Left by alex on May 31, 2011 1:21 AM

    # re: Passing Multiple Query String Variables Using SPD – Follow Up on Creating Parent / Child List Relationships
    Requesting Gravatar...
    HI Mark, update on my previous post. I found a work around my problem by modifying the target cell on child list to be single line text instead of dropdown. That no allows to also pass "Company Name" variable and save on form. No: Of course advanced users would have known this. When i pass some Company Name that has a & in the name, that name gets parsed and only first bit come over. I am not sure whether my problem is clear, nevertheless i try: any clues how i can make not parse on a single & for that page, but to parse for example on 2& in a row only ?
    Left by alex on Jun 01, 2011 2:40 PM

    # re: Passing Multiple Query String Variables Using SPD – Follow Up on Creating Parent / Child List Relationships
    Requesting Gravatar...
    It WAS working for me... not I'm getting this error:

    'Invalid data has been used to update the list item. The field you are trying to update may be read only. '

    What did I do? I'm passing 2 QS parameters
    Left by L01$Lane on Jun 06, 2011 2:47 PM

    # re: Passing Multiple Query String Variables Using SPD – Follow Up on Creating Parent / Child List Relationships
    Requesting Gravatar...
    am receiving the same error now as L01$Lane, my site had also been working and now has issues. The parameter passes properly onto the newform but when saving we receive the same "invalid data" error that L01S receives
    Left by dan on Jul 08, 2011 1:45 PM

    # re: Passing Multiple Query String Variables Using SPD – Follow Up on Creating Parent / Child List Relationships
    Requesting Gravatar...
    Sounds like you are running into the +/- 20 item "feature" of Lookup Lists. This blog post should help:

    http://geekswithblogs.net/SoYouKnow/archive/2011/04/06/setting-sharepoint-drop-down-lists-w-jquery---20-items.aspx

    Good luck,
    Mark
    Left by Mark Rackley on Jul 08, 2011 1:53 PM

    # re: Passing Multiple Query String Variables Using SPD – Follow Up on Creating Parent / Child List Relationships
    Requesting Gravatar...
    Tried to follow the info contained on http://geekswithblogs.net/SoYouKnow/archive/2011/04/06/setting-sharepoint-drop-down-lists-w-jquery---20-items.aspx

    but found it a bit confusing. Do I need to edit both the newpage and the original dispform with the code? I tried only changining the newform and still received the same error.
    Left by dan on Jul 11, 2011 9:08 AM

    # re: Passing Multiple Query String Variables Using SPD – Follow Up on Creating Parent / Child List Relationships
    Requesting Gravatar...
    Do you have any plans on incorporating the information contained in the new link you provided into your video remix of creating the parent/child relationship? I still find this a bit confusing and continue to receive errors after incorporating the code into the newform.
    Left by dan on Jul 19, 2011 9:35 AM

    # re: Passing Multiple Query String Variables Using SPD – Follow Up on Creating Parent / Child List Relationships
    Requesting Gravatar...
    Hi can you please tell me , how to pass querystring variable to EDIT item page. with or without using EditItemWithCheckoutAlert function ...
    Left by Atarpan on Dec 08, 2011 12:08 AM

    Your comment:
     (will show your gravatar)


    Copyright © Mark Rackley | Powered by: GeeksWithBlogs.net