I'm trying to add all formulas existent in a report, to another report if they don't already exist.
I'm using the following code:
foreach (FormulaField formula in baseReport.ReportClientDocument.DataDefinition.FormulaFields)
{
FormulaField field = (FormulaField) customReport.ReportClientDocument.DataDefinition.FormulaFields.FindField(
formula.Name,
CrFieldDisplayNameTypeEnum.crFieldDisplayNameName,
CeLocale.ceLocalePortuguese);
if (field == null)
{
// Add new formula
customReport.ReportClientDocument.DataDefController.FormulaFieldController.Add(formula);
}
}
Note: baseReport and customReport are of type ReportDocument.
The problem is that when it tries to add a sql expression field, I get an exception:
COMException: The report doesn't support the formula syntax.
Am I missing something here? Is there any other way to add sql expression fields?
Thanks