none
Passing ID variable from the parent to the child new item form RRS feed

  • Question

  • Version Sharepoint 2010

    Parent = Review   Child = Request

    1. Created Display form in Review that displays 1 record in the Parent with multiple Child information.  
    2. Added Data View for Request below the Review webpart.
    3. Added filter to only display those child items by adding Filter ReviewID = [ParamReview]  Where ParamReview = QueryString = ID
    4. Created New Request form 
    5. Changed ReviewID to Textbox
    6. Added Parameter ParamReviewID Where QueryString = ReviewID
    7. Added text="{$ParamReviewID}"
    8. In Display Form I added the following hyperlink to link to this new Request form
    9. <a href="../../Lists/[My Site]/NewForm.aspx?ReviewID={$ParamReview}" onclick="javascript.this.href = unescapeProperly(escape(this.href)); GoToLink(this); return false;" target="_self">Add New Item</a>

    I believe my issue lies in this hyperlink.  I have tried @ParamReview, @ReviewID, @ID and everything i put into this automatically gets displayed in the New Request Form Review ID Text box.  So in this above example, when I click on this link it displays in my ReviewID text box $ParamReview.    If I manually put ReviewID = 1 in my hyperlink, then it will display in my textbox 1.  

    I am having difficulties with restrictions at work in order to use Jscript because I don't have access to Content Editor, so I am trying this as the alternative since I don't have much choice.

    Thanks and any suggestions/help would be greatly appreciated.  


    Thursday, January 7, 2016 3:25 PM

Answers

  • Problem:  I created a hyperlink below the child data view that was completely separate from the Child "Add New Item" link 

    Solution:   In my Review Display form with Parent/Child, First I clicked on the Child Webpart, Then Clicked in the Ribbon Design tab/Options/Summary.  Then I clicked on the Add New Item control and it had an arrow to add a Hyperlink, I clicked ok and yes to add hyperlink, this is how it showed me the xsl:template in order to update this.  Once I did all of this I then went to <xsl:Choose>  Where this hyperlink is stored.  I then pasted my hyperlink over the href <xsl:otherwise> <a class="ms-addnew" id="{ID}-{WPQ}" href="./../Lists/[My Site]/NewForm.aspx?ReviewID={$ParamReview}"  I think I had to play with this a few times, and ended up using the href=https:// full website path with the Parameter ReviewID={$ParamReview}

    Then I also updated the onclick commandonclick="javascript.this.href = unescapeProperly(escape(this.href)); GoToLink(this); return false;" target="_self">

    I also removed the <xsl:value-of select="$AddNewText"/> and put simply Add New Item as the label

    Finally, In order for the Hyperlink and Parameter to work.  I opened Tag Properties of this "Add New Item" Hyperlink.  In the Href Property I clicked on the Fx button and I copied the ./../Lists/[My Site]/NewForm.aspx?ReviewID={$ParamReview} and pasted it into the dialog box and it automatically changed it to NewForm.aspx?ReviewID={$ParamReview} and now it works great

    I got much of this from videos from Mark Rackley https://www.youtube.com/watch?v=bO1lc_mEThc

    So essentially this works in SharePoint 2010 without having to write any Java script code. 

    SECOND ISSUE regarding this!!  The Display and Edit forms work perfectly in the child of the Review Display Form, but the only issue with doing this above code is that it links you to the Requests Lists and once you click the Save button it takes you to the Request All Items.  Which is not what I wanted.  I need to redirect them to the Review Display form and have it continue filtering the same Review they were on.  I did this by doing the following code and it works perfectly for the SAVE and Cancel buttons to take me back to the Parent list: 

    First, I removed the Save/Cancel Buttons

    Second, Wrote the following code in that spot:

    <a>

    <xsl:attribute name="href">javascript: <xsl:value-of select="ddwrt:GenFireServerEvent(concat('__commit;__redirect={https:// full website path/lists/Review/ReviewDisplayForm.aspx?ID=',$ParamReviewID,'}'))" /><xsl:attribute>Save</a>

    Third, I did this same code for Cancel, except I took out the __commit and changed the Save to Cancel Text.  


    Friday, January 8, 2016 3:21 PM

All replies

  • Problem:  I created a hyperlink below the child data view that was completely separate from the Child "Add New Item" link 

    Solution:   In my Review Display form with Parent/Child, First I clicked on the Child Webpart, Then Clicked in the Ribbon Design tab/Options/Summary.  Then I clicked on the Add New Item control and it had an arrow to add a Hyperlink, I clicked ok and yes to add hyperlink, this is how it showed me the xsl:template in order to update this.  Once I did all of this I then went to <xsl:Choose>  Where this hyperlink is stored.  I then pasted my hyperlink over the href <xsl:otherwise> <a class="ms-addnew" id="{ID}-{WPQ}" href="./../Lists/[My Site]/NewForm.aspx?ReviewID={$ParamReview}"  I think I had to play with this a few times, and ended up using the href=https:// full website path with the Parameter ReviewID={$ParamReview}

    Then I also updated the onclick commandonclick="javascript.this.href = unescapeProperly(escape(this.href)); GoToLink(this); return false;" target="_self">

    I also removed the <xsl:value-of select="$AddNewText"/> and put simply Add New Item as the label

    Finally, In order for the Hyperlink and Parameter to work.  I opened Tag Properties of this "Add New Item" Hyperlink.  In the Href Property I clicked on the Fx button and I copied the ./../Lists/[My Site]/NewForm.aspx?ReviewID={$ParamReview} and pasted it into the dialog box and it automatically changed it to NewForm.aspx?ReviewID={$ParamReview} and now it works great

    I got much of this from videos from Mark Rackley https://www.youtube.com/watch?v=bO1lc_mEThc

    So essentially this works in SharePoint 2010 without having to write any Java script code. 

    SECOND ISSUE regarding this!!  The Display and Edit forms work perfectly in the child of the Review Display Form, but the only issue with doing this above code is that it links you to the Requests Lists and once you click the Save button it takes you to the Request All Items.  Which is not what I wanted.  I need to redirect them to the Review Display form and have it continue filtering the same Review they were on.  I did this by doing the following code and it works perfectly for the SAVE and Cancel buttons to take me back to the Parent list: 

    First, I removed the Save/Cancel Buttons

    Second, Wrote the following code in that spot:

    <a>

    <xsl:attribute name="href">javascript: <xsl:value-of select="ddwrt:GenFireServerEvent(concat('__commit;__redirect={https:// full website path/lists/Review/ReviewDisplayForm.aspx?ID=',$ParamReviewID,'}'))" /><xsl:attribute>Save</a>

    Third, I did this same code for Cancel, except I took out the __commit and changed the Save to Cancel Text.  


    Friday, January 8, 2016 3:21 PM
  • Hi,

    Thanks for your sharing! It will be beneficial to others in this forum who meet the same issue in the future.

    Best Regards,

    Wendy


    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact tnmff@microsoft.com.

    Monday, January 11, 2016 1:20 AM
    Moderator
  • Super man of steel,

    Can you elaborate in more detail on the code below. Does this go in a CEWP? How is the button displayed? I did not get to work correctly.

    <a> <xsl:attribute name="href">javascript: <xsl:value-of select="ddwrt:GenFireServerEvent(concat('__commit;__redirect={https:// full website path/lists/Review/ReviewDisplayForm.aspx?ID=',$ParamReviewID,'}'))" /><xsl:attribute>Save</a>

    I did this following your post and inserted in a content editor webpart

    <a> <xsl:attribute name="href">javascript: <xsl:value-of select="ddwrt:GenFireServerEvent(concat('__commit;__redirect={http://sp-svr/Lists/SystemEffort/NewForm.aspx?ID=',$ParamReviewID,'}'))" /><xsl:attribute>Save</a>

    The Save hyperlink is display as so

    <xsl:attribute name="href">javascript: <xsl:value-of select="ddwrt:GenFireServerEvent(concat('__commit;__redirect={http://sp-svr/Lists/Sytemz/DispForm_ST.aspx?ID=',$ParamReviewID,'}'))"><xsl:attribute>Save</xsl:attribute></xsl:value-of></xsl:attribute>

    Tuesday, January 10, 2017 4:19 PM