SAP Knowledge Base Article - Public

1549732 - How can I view or modify a conditional hyperlink located in a Crystal Report subreport?

Symptom

I have a conditional hyperlink in a subreport, how can I change or view the hyperlink using the RAS .NET SDK?

Resolution

You can use the following VB.NET RAS code to access the subreport and the hyperlink off of a Crystal Reports subreport object:

Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.ReportAppServer.ClientDoc
Imports CrystalDecisions.ReportAppServer.DataDefModel
Imports CrystalDecisions.ReportAppServer.Controllers
Partial Class _Default
    Inherits System.Web.UI.Page
    Dim crRpt As New ReportDocument
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        'load the report
        crRpt.Load("C:\Reports\MyReportwithSubHyperlinkObject.rpt")
        Dim rcd As ISCDReportClientDocument
        'Get the report as a ReportClientDocument
        rcd = crRpt.ReportClientDocument
        'Create a ReportClientDocument for the Subreport
        Dim subRCD As SubreportClientDocument
        'Grab the Subreport
        subRCD = rcd.SubreportController.GetSubreport("MySubreportName")
        'Get the ReportDefController2 for the sub
        Dim myReportDefController As ReportDefController2 = subRCD.ReportDefController
        'Create a field object to hold the hyperlink object
        Dim myHLObj As New CrystalDecisions.ReportAppServer.ReportDefModel.FieldObject
        'Clone the field we want to change the hyperlink of
        myHLObj = CType(subRCD.ReportDefController.ReportDefinition.FindObjectByName("MyFieldName").Clone(True), CrystalDecisions.ReportAppServer.ReportDefModel.FieldObject)
        'You can use this to get the existing hyperlink text
        'Dim s As String = myHLObj.Format.ConditionFormulas.Formula(CrystalDecisions.ReportAppServer.ReportDefModel.CrObjectFormatConditionFormulaTypeEnum.crObjectFormatConditionFormulaTypeHyperlink).Text
        'Set the hyperlinks text to whatever you want
        myHLObj.Format.ConditionFormulas.Formula(CrystalDecisions.ReportAppServer.ReportDefModel.CrObjectFormatConditionFormulaTypeEnum.crObjectFormatConditionFormulaTypeHyperlink).Text = "Your new hyperlink"
        'Modify the object
        myReportDefController.ReportObjectController.Modify(subRCD.ReportDefController.ReportDefinition.FindObjectByName("MyFieldName"), myHLObj)
        'Save the report
        rcd.Save()
    End Sub
End Class

Keywords

.net net dotnet RAS Crystal Report subreport hyperlink conditional x+2 , KBA , BI-DEV-NET , BI Software Development Kits (SDKs) - .NET or Other , Problem

Product

Crystal Reports 2008 V1 ; Crystal Reports Server 2008 V1, OEM edition ; SAP Crystal Reports XI R2