Skip to Content
0

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

Feb 09, 2017 at 09:26 PM

82

avatar image
P R

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.

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

3 Answers

Dell Stinnett-Christy Feb 10, 2017 at 02:39 PM
0

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

-Dell

Share
10 |10000 characters needed characters left characters exceeded
P R Feb 10, 2017 at 08:15 PM
0

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.

Share
10 |10000 characters needed characters left characters exceeded
Don Williams
Mar 21, 2017 at 06:21 PM
0

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

Share
10 |10000 characters needed characters left characters exceeded