Link to home
Start Free TrialLog in
Avatar of ndidomenico
ndidomenico

asked on

How to change field names in a report layout using a script

Is it possible to specify the name of a field to be printed on a report layout using a script ?

I have a report that has to be printed 6 different ways. The 6 reports are almost identical, where the only difference resides in the name of 1 field that changes in each of these reports. So I would like to create only 1 layout instead of 6, and use a script (or whatever technique appropriate) that would get the proper field name to print, based on a selection made by the user.

Is this possible ?

Thanks.
Avatar of Member_2_908359
Member_2_908359
Flag of France image

you can use a seventh field for the layout, calculated from the other 6 values + the report type:
7th field definition =
case (
report_type=1 ; data1 ;
report_type=2 ; data2 ;
report_type=3 ; data3 ;
report_type=4 ; data4 ;....
)

 or
use a normal 7th text field and have the print script to change its value accordingly.
Avatar of ndidomenico
ndidomenico

ASKER

I think I understand your suggestion and got it to work. Thanks !
Below are the steps I used. Is this what you had in mind?:
1) Create a calculated, unstored field named Field7 which returns a Text value
2) Entered the "case..." statement in the field definition.
3) Created a global field called report_type which gets set by my script (1,2,3..)

Now, for your 2nd option, I'm not sure I understand properly. Is this 7th field a "regular" text field (not calculated, not global) and put in there one of the 6 field names ?. Could you give me more details ?

Thanks
1
roughly, yes. the global field for the report type could have been a variable too.
2
yes, instead of using a calc. field, your script calculates the result and put it in a regular field. fairly equiv. to solution 1
2:
In this scenario, the script must calculate the result for each and every record in the table before printing the report ?

I was hoping for a solution where the script could store in a global the name of the field that has to be printed on the layout, and use this global in the layout to get the appropriate field to print. Doesn't work that way, right ?



ASKER CERTIFIED SOLUTION
Avatar of Member_2_908359
Member_2_908359
Flag of France image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks for the solution. Works great! I'm using the calc. field + global for the field name method.
perfect then