Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I am trying to create a formula for a dataview that returns a URL using the xpath expression tool in SPD 2007. I can't really find any examples. Here is what I am trying to do (in pseudo code):

If @ColumnA='SomeValue' then

// build a link to a web page and display it in the column
'<a href=http://mysite/somePage.aspx?ParamB=' + @ColumnB + '&ParamC=' + @ColumnC + '>Complete Request</a>'

else

// display nothing in the column
''

end

The url should look like this:

http://abc-company/somepage.aspx?ParamB=1234&ParamC=ABCD

and displayed in the dataview list column as a URL (if condition is true) labeled "Complete Request"

share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

So the way I did this was to just add a simple formula column. Then, in the markup, I replaced what was added by the designer with this:

<xsl:choose>
<xsl:when test="@OARP_x0020_Approval_x0020_Status='Initializing'">
    <td class="ms-vb">
        <xsl:element name="a">
            <xsl:attribute name="href">
                <xsl:value-of select="concat(concat('oracleResponsibilities.aspx?GUID=',@Guid_Id),concat('&amp;ID=',@ID))"/>
            </xsl:attribute>
            <xsl:text>Complete Request</xsl:text>
        </xsl:element>
    </td>
</xsl:when>
<xsl:otherwise>
    <td class="ms-vb"></td>
</xsl:otherwise>

Basically, if the value of column "OARP Approval Status" is 'Initializing', then I construct the anchor tag. If "OARP Approval Status" is any other value, I just leave the table cell blank.

The following creates the anchor tag:

<xsl:element name="a"></xsl:element>

This sets the href attribute:

<xsl:attribute name="href">
    <xsl:value-of select="concat(concat('oracleResponsibilities.aspx?GUID=',@Guid_Id),concat('&amp;ID=',@ID))"/>
</xsl:attribute>

And this sets the display value fo the link:

<xsl:text>Complete Request</xsl:text>
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.