RE: Getting code control of the DisplayString formatting formula
in particular Don Williams (ref. thread [“Display string” formatting formula|“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
- rptDoc.ReportClientDocument.ReportDefController.ReportObjectController.Modify(col, colTemp)
- 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