Symptom
Existing Report with {} in the formula name causes Crystal Reports Designer to be slow to open the report
In a CR for VS Windows .NET app it may fail to load report and/or it may generate an error - error in formula
Environment
- Crystal Reports Designer 2008 and higher ( Note: this likely was always allowed but may have generated various errors when attempting to use them)
- Crystal Reports For Visual Studio
Reproducing the Issue
Open your report in CR Designer, notice formula name has a field reference in the name
- Example {abc}
Using CR for VS .NET SDK the following will return zero formula count, if it's the only one:
- MessageBox.Show (rptClientDoc.DataDefController.DataDefinition.FormulaFields.Count.ToString());
If more than one formula then to verify if the formula is valid use the following:
-
String FormulaMessage = rptClientDoc.DataDefController.FormulaFieldController.Check(resultField);
if (FormulaMessage != null)
{
btnReportObjects.Text += FormulaMessage.ToString() + "\n";
}
Cause
These characters are used internally for labeling various Report Objects and should not be used when creating those objects, formula.
CR Designer allowed them to be created but would often cause issues when previewing or using the in a .NET Windows application
NOTE: most software venders typically use any character on the Shift Top row characters of your keyboard as reserved characters. Avoid using any of them. Crystal Reports Designer will aloow them but the SDK's will not
Resolution
The following Adapt was created to not allow users to use those characters when designing reports - ADAPT01728520
The updated Crystal Reports Designer will begin with CR 2011 SP 11 and Crystal Reports for Visual Studio embedded Designer in SP 11 and all future releases.
Note: to update the reports you will need to open each one and "fix" it manually
To catch the inner exception use the following in a Try/Catch block when opening the report:
try
{
rpt.Load(rptName.ToString(), OpenReportMethod.OpenReportByTempCopy);
}
catch (Exception ex)
{
if (ex.Message.ToString() == "Load report failed.")
{
MessageBox.Show("ERROR: Load report failed: " + ex.InnerException.Message.ToString());
}
}
A complete list of this reserved character limitation in CR and our SDK:
CRW w/o Fix |
CRW with Fix |
RAS .Net SDK w/o Fix |
RAS .Net SDK with fix |
RAS Java SDK w/o Fix |
RAS Java SDK with fix |
|
open rpt contains formula name with @ ? |
✓ |
✓ |
✓ |
✓ |
✓ |
✓ |
create formula name with @ ? |
✓ |
✘ |
✓ |
✘ |
✓ |
✘ |
modify content of the formula name with @ ? and save |
✓ |
✓ |
✓ |
✘ |
✓ |
✘ |
re-name formula to @ ? |
✓ |
✘ |
N/A |
N/A |
N/A |
N/A |
open rpt contains formula name with { |
✓ |
✓ |
✓ |
✓ |
✓ |
✓ |
create formula name with { |
✓ |
✘ |
✓ |
✘ |
✘ |
✘ |
modify content of the formula name with { and save |
✓ |
✓ |
✓ |
✘ |
✘ |
✘ |
re-name formula to { |
✓ |
✘ |
N/A |
N/A |
✘ |
✘ |
open rpt contains formula name with } |
✓ |
✓ |
✘ |
✘ |
✘ |
✘ |
create formula name with } |
✓ |
✘ |
✓ |
✘ |
✘ |
✘ |
modify content of the formula name with } and save |
✓ |
✓ |
✘ |
✘ |
✘ |
✘ |
re-name formula to } |
✓ |
✘ |
N/A |
✘ |
✘ |
✘ |
✘: new error message Error in formula name ‘formula_name_placeholder’, reserved characters "{", "}", "@", "?" cannot be used in formula name.
✘: old error message Invalid field name. formula_name_placeholder
✘: old error message The name of a formula, parameter or running total field cannot include { and }---- Error code:-2147213302 [CRSDK00000241] Error code name:invalidFormulaField
N/A: SDK could not re-name formula, FormulaFieldController.Modify(OldFormulaField, NewFormulaField) will return message The Name property of the old and new formula fields must be the same.
See Also
1214114 - Error: This field name is not known when attempting to save or verify a formula in Crystal Reports
Keywords
‘@’,’?’,’{‘,’}’, Crystal Reports, Crystal Reports for Visual Studio, error in formula, reserved characters '{', '}', '@', '?', , reserved characters '{', '}', '@', '?' cannot be used in formula name , KBA , BI-RA-CR-SDK , SDK related, including Java/.NET etc. , BI-RA-CR , Crystal Reports designer or Business View Manager , Problem