cancel
Showing results for 
Search instead for 
Did you mean: 

How to rename a formula field using Crystal Reports for Visual Studio and Report Application Server?

0 Kudos

Hi,

Is it possible to rename a formula field using Crystal Reports for Visual Studio and the Report Application Server (RAS)?

I see a Modify method, but it requires that the old formula field name match the new formula field name. I'm not seeing anything in the documentation that will allow me to rename the formula. I can get the name for the current formula, remove it, and add a new formula, but that would likely cause the old formula to be removed from charts/cross-tabs on the report.

Thanks.

Accepted Solutions (1)

Accepted Solutions (1)

0 Kudos

You should be able to .Clone the formula field and then delete and add it back in with it affecting other objects. Although that may cause the engine to delete all references to it.

If that doesn't work then there should be a Modify() to alter the field formula info.

Don

Answers (2)

Answers (2)

0 Kudos

I'm using what I call "wrapper" formulas for fields that are included from the database. I do this so I can use the "wrapper" formulas in cross-tabs and charts. This allows me to comment out the code and even rename the formulas without the cross-tab or chart disappearing on me (or having any of the formatting reset). I usually name these in the format "Wrapper-{Table or Command Name}.{Field Name}" where {Table or Command Name} is the actual table or command where the field comes from and {Field Name} is the actual field name.

Sometimes, the table or command name has to change for whatever reason and I'd like to be able to rename the formulas to match table/command in code because there are often a lot of formulas and doing this programmatically would save me a lot of time. I already use similar code that obtains the formula text and checks the spelling before using the FormulaFieldController class to save the changes, which has saved me a ton of time.

If I have to obtain the formula text and use the Remove and Add methods to rename a formula, then my cross-tabs and charts will likely disappear (or at the very least the formatting will reset).

I really don't want to have to search for every instance of the formula and have to try to capture all the settings for the cross-tabs and charts because I already know there are some settings that aren't exposed in code and I'll have to touch most of them to return them to their previous state.

DellSC
Active Contributor
0 Kudos

Is there a particular reason why you need to rename the formula in code? I don't think it's possible.

-Dell