Adding a hyperlink or button to a XsltListViewWebPart that sends field values as query string parameters from the current view row to a form
-
Thursday, July 15, 2010 8:44 PM
What I'm trying to do:
I'm working in SharePoint 2010 with SPD2010 and InfoPath 2010.
I have two lists - one for proposed investment projects and one for votes. I have set up all the necessary lookup fields between these two lists. I'm trying to find a way so that when a user sees a project they want to vote for they can click a button or link on that projects row in the view and have it take them to the newform.aspx of the child list (Votes). I also want to add some parameters to that URL link so that the child form pre-populates the "Proposal Name" field which is the lookup relationship between the two lists:
What I have done that is working fine:
- Created the view and added the link to the newform.aspx (both with a button and by formatting a column value as hyperlink) in SPD 2010
- Edited the newform.aspx to include a CEWP that contains jQuery and fpss code to handle the prepopulation (this works when called directly with parameters)
What I need help with please:
Whatever I do I cannot get the URL to pass the value of the" Project Proposal" field on the current row as a query string parameter. I have tried:
1) Formatting a row item as a hyperlink. Setting the "xsl:value-of" menu hyperlink options to include the field name (both as "XSL:Project Proposal" and as a query string parameter (newform.aspx?Title={@Title}).2) Adding a column to the view in which I put a form button. In the Form Actions I've used a "Navigate to Page" action and set parameters as above
Both methods correctly navigate to the form but neither pulls in the dynamic filed value from the current row as I want. The button just sends the {@Title} itself and the value url link sends nothing.
Any help much appreciated. If I can get this working it will really make the solution much more friendly to the end user as I can make sure votes get applied to the right project without relying on them to re-select the right project on the child form.
Many thanks -- Richard
PS: Thought the code may be useful. This is what SPD 2010 generates for the code: (I have not manually altered this at all)
My attempt to configure a form button:
<input name="Button1" type="button" value="button" onclick="javascript: {ddwrt:GenFireServerEvent('__redirect={../rksb/Lists/Test Jscript/NewForm.aspx?Title_x003D__x007B_@Title_x007D_}')}" />
..and my attempt to use a row value formatted as hyperlink with parameters
<xsl:template name="FieldRef_Text_body.Click_x0020_to_x0020_Vote" ddwrt:dvt_mode="body" match ="FieldRef[@Name='Click_x0020_to_x0020_Vote']" mode="Text_body" ddwrt:ghost="" xmlns:ddwrt2="urn:frontpage:internal"><xsl:param name="thisNode" select="."/><xsl:choose><xsl:when test="@AutoHyperLink='TRUE'"><xsl:value-of select="$thisNode/@*[name()=current()/@Name]" disable-output-escaping ="yes"/></xsl:when><xsl:otherwise><a href="../rksb/Lists/Test Jscript/NewForm.aspx?Title={$thisNode/@Title}"><xsl:value-of select="$thisNode/@*[name()=current()/@Name]" /></a></xsl:otherwise></xsl:choose></xsl:template>
All Replies
-
Sunday, July 18, 2010 2:10 AM
OK so here is what I did. I have SP2007 open.
- made new team site and opened the default page and dropped in a DFWP for the tasks list
- clicked "add Column" and picked one of the fields I wanted to pass as a query string parameter and formatted it as a hyperlink. It popped up a window of what url I want
- my hyperlink looks like <a href="http://server:8889/Lists/Tasks/NewForm.aspx?RootFolder=%2FLists%2FTasks&Source=http%3A%2F%2Fserver%3A8889%2FLists%2FTasks%2FAllItems%2Easpx&Status={@Status}">Copy Task</a>
- Edited the NewForm page of the tasks list where I removed the listformwebpart and added a custom list form (actually another DFWP)
- Added a new parameter to the custom list form thats names Status and is of type QueryString
- Heres where you kind of hit a wall because the SharePoint form fields do not work with parameters. You can choose to use javascript here, or you can use other controls than SharePoint:FormField controls. Left to my own devices id do the latter.
- For the tasks list the status field is a dropdown so I replaced the formfield with
<SharePoint:DVDropDownList runat="server" id="ff3{$Pos}" selectedvalue="{$Status}" __designer:bind="{ddwrt:DataBind('i',concat('ff3',$Pos),'SelectedValue','SelectedIndexChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@Status')}">
<asp:listItem>Not Started</asp:listItem>
<asp:listItem>Completed</asp:listItem>
</SharePoint:DVDropDownList>note I was too lazy to add all the valid values for status. If you're feeling fancy you can data drive the dropdown too.
Lemme know if you're still unclear about anything. Here is a blog very close to what I did
- Marked As Answer by Aaron Han - MSFT Monday, July 26, 2010 1:49 AM

