cancel
Showing results for 
Search instead for 
Did you mean: 

Getting code control of the DisplayString formatting formula

Former Member
0 Kudos

Hi everybody,

in particular Don Williams (ref. thread ["Display string" formatting formula|] from the Legacy Application Development SDKs forum).

I want to get control of the DisplayString formatting formula from code. I use Crystal Reports XI R2 and Visual Studio 2005. According to Don Williams in the referenced thread:

-


I had a look in our new report engine included with CR XI R2 (11.5) SP 2 RAS and it appears this feature is available.

Public Const crObjectFormatConditionFormulaTypeDisplayString As CrystalDecisions.ReportAppServer.ReportDefModel.CrObjectFormatConditionFormulaTypeEnum = 9

Member of: CrystalDecisions.ReportAppServer.ReportDefModel.CrObjectFormatConditionFormulaTypeEnum

-


From this, I assume that the mentioned functionality should be available in my programming environment.

In Crystal Reports XI Designer, I can set a formula for the Display String. This works fine.

For various other issues (ToolTip, HyperLink, FontColor..) I can get to the correponding ConditionFormula from code, via the ReportClientDocument object model. However, the DisplayString condition formula returns nothing in code even if I inserted a formula there in the designer.

Where does the Designer store the display string formatting formula?

I would expect the following to work, but my lstr always returns nothing even if I inserted a formula in the designer. Also, it doesn't work to insert a DisplayString formula like I do below - it won't take effect.

Private Sub SetContentFormula(ByVal pstrFieldName As String, ByVal pstrFormula As String)
        ' crRepDef is type CrystalDecisions.ReportAppServer.ReportDefModel.ISCRReportDefinition
        Dim col As ISCRFieldObject = CType(crRepDef.FindObjectByName(pstrFieldName), ISCRFieldObject)
        Dim lstr As String = col.Format.ConditionFormulas.Formula(CrObjectFormatConditionFormulaTypeEnum.crObjectFormatConditionFormulaTypeDisplayString).Text
        If lstr Is Nothing Then
            'Create a new formula for this object (i.e. this column in the report)
            Dim cf As ISCRConditionFormula = New ConditionFormula
            Dim colTemp As ISCRFieldObject = col
            cf.Text = pstrFormula
            cf.CopyTo(colTemp.Format.ConditionFormulas.Formula(CrObjectFormatConditionFormulaTypeEnum.crObjectFormatConditionFormulaTypeDisplayString))
            rptDoc.ReportClientDocument.ReportDefController.ReportObjectController.Modify(col, colTemp)
        Else
            col.Format.ConditionFormulas.Formula(CrObjectFormatConditionFormulaTypeEnum.crObjectFormatConditionFormulaTypeDisplayString).Text = pstrFormula
        End If
    End Sub

I donu2019t see how I can solve this with formula fields because of my overall design. I have only one .rpt file working as a template. In it I have heading fields, column fields etc. and I run a lot of reports against it. Each report is defined 100% in an .xml file, which contains formatting formulas and other things. These formulas apply to different report columns (i.e. field objects) for different reports. My software takes the .xml file as input, fetch the report data (as specified in the xml file), applies formatting formulas etc. to the various fields and everything works fine. Except the DisplayString formula.

If this is a bug in Crystal Reports XI R2, how can I find out if it is fixed and if so get a fixed software?

Thank you for help

Kjell Arne

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hello, Kjell;

What updates do you have on your Crystal Reports XI R2?

If you go to C:\Windows\Assembly\CrystalDecisions.CrystalReports.Engine.dll, right click and go to Properties|Version tab, what is the full version of the file? 11.5.97xx.xxx

Elaine

Answers (7)

Answers (7)

Former Member
0 Kudos

Hello, Kjell


Did you managed to solve?


Thks

Former Member
0 Kudos

Now I have updated to CR 2008 SP1 and the code (referred above) still doesn't work.

What is magic about the DisplayString? Quite similar code works fine for e.g. ToolTip.

And DisplayString works fine when set in the Crystal Report designer. But I need to update it from code ...

Regarding the code above: I have tried to Dim col as both ISCRReportObject and ISCRFieldObject, but none

of them work. Strange, since ToolTip (and more) are part of the same Enum, the CrObjectFormatConditionFormulaTypeEnum.

Is the crObjectFormatConditionFormulaTypeDisplayString still a problem in CR2008 SP1 or am I doing something wrong?

Please point me in the right direction. This was the main reason for going to CR2008 ...

If I search for DisplayString in the documentation (Developer Guide or API Reference) I get "No topics found".

Still, it shows up in Intellisense and is part of the Enum, so I would expect it to work.

- Kjell Arne

Former Member
0 Kudos

Dear Elaine,

Please let me know also if you can NOT narrow down what update made it available. It is interesting also for other readers of this thread. If you figure out where the fix is, please also let me know how to get it (SAP / Business Objects web pages aren't always that easy to navigate)...

\- Kjell Arne

Former Member
0 Kudos

Hello, Kjell;

The property "crObjectFormatConditionFormulaTypeDisplayString" is public in the Report Application Server SDK properties for Business Objects Enterprise or Crystal Reports 2008.

I believe it also became available for use in a late update to Crystal Reports XI R2 though I cannot see it in the documentation. If I can narrow down what update made it available, I will let you know.

It was not public in Crystal Reports XI R2 SP 2 which you are using. You are seeing the property but I suspect the engine is ignoring it.

Elaine

Former Member
0 Kudos

Hi Elaine,

This time I did get the popup after right-click! Hmm. Maybe I had the program running yesterday, or something...

Anyway, for the 11.5.3700.0 file (MSIL Processor Architecture) it says

File Version 11.5.9708.826

Private Build Description 9708.826.3321.0

Thank you for your patience ...

\- Kjell Arne

Former Member
0 Kudos

Hello, Kjell;

I want to check the Service Pack version so I need you to go to the file in Explorer through Windows\Assembly , Right click on the 11.5.3700.0 file, choose Properties and then you should see a version tab that will give the full Crystal Reports version.

Thank you!

Elaine

Former Member
0 Kudos

Dear Elaine,

In my C:\Windows\Assembly\ there are actually four files named CrystalDecisions.CrystalReports.Engine. Two of them have Processor Architecture MSIL and two have no indication of Processor Architecture.

For the MSILs, they have versions 11.5.3700.0 and 10.2.3600.0

For the two others, they have versions 11.5.3300.0 and 11.0.3300.0

The Culture is blank for all of them. They all have the same Public Key Token.

(I don't have a right-click pop-up menu for these, but I can see the Version directly in the Explorer).

Thank you for helping me!

\- Kjell Arne