Does printing cause SSRS to re-render, and if so is there any way around it?

I posted this question to Stack Overflow and haven't had a bite, so I thought I might try here:

I have a report I'm building in SSRS.  I have text box that makes use of custom code at the bottom of the report (not in the footer).  This is the function in use:

    =Code.WinnerTextBox(First(Fields!WinnerName.Value, "FightDetails" ),First(Fields!Blue_Corner.Value, "Judge1"),First(Fields!Red_Corner.Value,"Judge1"),First(Fields!FightDecisionCode.Value, "FightDetails" ),First(Fields!DecisionTypeName.Value, "FightDetails" ),First(Fields!FightDecisionRoundNo.Value, "FightDetails" ), First(Fields!FightDecisionTime.Value,"FightDetails" ),First(Fields!SubmissionTypeName.Value, "FightDetails" ))
Here is the custom code in use:
Public Class CalculateTotals
                    Dim public redTotal AS Integer
                    Dim public redRoundTotal AS Integer
                    Dim public blueTotal AS Integer
                    Dim public blueRoundTotal AS Integer
    
                    Public Function AddRedTotal(ByVal RedCornerDeduction AS Integer, ByVal RedCornerPoints AS Integer) AS Integer
                                    redRoundTotal = RedCornerPoints - RedCornerDeduction
                                    redTotal = redTotal + redRoundTotal
                                    return redRoundTotal
                    End Function
    
                    Public Function GetFinalRed()
                                    return redTotal
                    End Function
    
                    Public Function AddBlueTotal(ByVal BlueCornerDeduction AS Integer, ByVal BlueCornerPoints AS Integer) AS Integer
                                    blueRoundTotal = blueCornerPoints - blueCornerDeduction
                                    blueTotal = blueTotal + blueRoundTotal
                                    return blueRoundTotal
                    End Function
    
                    Public Function GetFinalBlue()
                                    return blueTotal
                    End Function
                    
                    Public Function GetLeaderName(ByVal RedName AS String, ByVal BlueName AS String) AS String
                                    IF GetFinalBlue() > GetFinalRed() Then
                                                    return BlueName
                                    ElseIf GetFinalRed() > GetFinalBlue() Then
                                                    return RedName
                                    ElseIf GetFinalRed() = GetFinalBlue() Then
                                                    return "Draw"
                                    Else
                                                    return "Something is very wrong with the data"
                                    End If
                    End Function
    End Class
    
    Dim Public Judge1 AS CalculateTotals = New CalculateTotals()
    Dim Public Judge2 AS CalculateTotals = New CalculateTotals()
    Dim Public Judge3 AS CalculateTotals = New CalculateTotals()
    Dim Public red AS Integer
    Dim Public blue AS Integer
    Dim Public leader AS String
    
    Public Function GetRed() AS Integer
                    red = Judge1.GetFinalRed() + Judge2.GetFinalRed() + Judge3.GetFinalRed()
                    return red
    End Function
    
    Public Function GetBlue() AS Integer
                    blue = Judge1.GetFinalBlue()+Judge2.GetFinalBlue()+Judge3.GetFinalBlue()
                    return blue
    End Function
    
        Public Function WinnerTextBox(ByVal Winner As String, ByVal BlueCorner As String, ByVal RedCorner As String, ByVal DecisionCode As Integer, ByVal DecisionType As String, ByVal DecisionRound As Integer, ByVal FightDecisionTime As String, ByVal SubmissionType As String) As String
            Dim ReturnString As String
            If (GetBlue() = GetRed()) Or (DecisionCode = 10) Or (DecisionCode = 11) Or (DecisionCode = 12) Then
                ReturnString = "Draw: " & CStr(GetBlue()) & "-" & CStr(GetRed()) & " (" & DecisionType & ")"
            ElseIf (Winner Is Nothing) Then
                If (GetBlue() > GetRed()) Then
                    ReturnString = "Leader: " & BlueCorner & CStr(GetBlue()) & "-" & CStr(GetRed())
                Else
                    ReturnString = "Leader: " & RedCorner & CStr(GetRed()) & "-" & CStr(GetBlue())
                End If
            ElseIf (DecisionCode = 1) Then
                ReturnString = "Winner: " & Winner & " By " & DecisionType & " In Round " & CStr(DecisionRound) & " At " & FightDecisionTime
            ElseIf (DecisionCode = 9) Then
                ReturnString = "Winner: " & Winner & " By " & DecisionType & " " & SubmissionType & " In Round " & CStr(DecisionRound) & " At " & FightDecisionTime
            ElseIf Winner = BlueCorner Then
                ReturnString = "Winner (" & CStr(GetBlue()) & "-" & CStr(GetRed()) & "): " & Winner & " By " & DecisionType & " In Round " & CStr(DecisionRound) & " At " & FightDecisionTime
            ElseIf Winner = RedCorner Then
                ReturnString = "Winner (" & CStr(GetRed()) & "-" & CStr(GetBlue()) & "): " & Winner & " By " & DecisionType & " In Round " & CStr(DecisionRound) & " At " & FightDecisionTime
            End If
            Return ReturnString
Now when the report is run, it renders absolutely correct on the screen, however when it is exported to PDF or printed, the textbox renders the following text:

Draw: 0-0 (KNOCKOUT)

This leads me to believe that the process of printing my report is causing the custom code to somehow try to run again, and has no data and therefore returns this.  Is there a way to prevent that from occurring?  Is that what is happening?  And if so, can you help me understand why it is re-rendering when printing?  Also, any suggestions on how to make this print properly?

July 27th, 2015 6:46pm

There are 3 stages: Data, Processing, and Rendering. This will re-render because you'll be using the report in a different format. If you are viewing the report in Internet Explorer, it has been rendered in HTML format. To print to PDF, it must be re-rendered to PDF format. It should be using the cached data though. I'm not sure whether the code is executed during processing or rendering. I'm also not sure if the Processing step is re-run on print. 
Free Windows Admin Tool Kit Click here and download it now
July 28th, 2015 3:00pm

It appears that it does.  I have opened a support ticket with Microsoft, but it seems like this is an issue with rendering custom code.  I will update when I have a solution.  In the meantime, I had to build an entirely separate query to build the string that goes in that textbox.  That works, but I would like to be able to use custom code in the future.
July 28th, 2015 4:30pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics