reporting-servicesssrs-2008rdlcustom-code

Compare two strings value in rdl file


I need to check the equality of two strings in rdl <code> file.

The below condition check only both or in Null values. but i need to check the parameter values are equal or not.

The below functions is custom function written in <code></code> block. Please help.

NPServedasperPolicy and NPServed parameter values are coming from reports values.

   public function getNoticePeriodStatus
        (byval NPServed as String,byval NPServedasperPolicy as String)


        if(NPServedasperPolicy = NPServed)
                getNoticePeriodStatus = "Notice period Fully Served"
        end if

Solution

  • Assuming you want to display:

    You could use the following custom code:

    Public Function GetNoticePeriodStatus (ByVal NPServed as String,ByVal NPServedasperPolicy as String)
            If((Not(NPServedasperPolicy Is Nothing) And Not(NPServed Is Nothing)) and NPServedasperPolicy = NPServed) Then
                    GetNoticePeriodStatus = "Notice period Fully Served"
            Else
                    GetNoticePeriodStatus = "Notice period Not Served"
            End If
    End Function
    

    That can be called with:

    =Code.GetNoticePeriodStatus(Parameters!NPServed.Value, Parameters!NPServedasperPolicy.Value)
    

    For completeness, here is the plain Expression equivalent:

    =Iif((Not(Parameters!NPServedasperPolicy.Value Is Nothing) And (Not(Parameters!NPServed.Value Is Nothing))) And Parameters!NPServedasperPolicy.Value = Parameters!NPServed.Value, "Notice period Fully Served", "Notice period Not Served")