PDA

View Full Version : Can you base a report column caption on a variable/alias?



Michael Macliver
17-Nov-2016, 10:43 AM
Hi,

Does anyone know if you can dynamically change a report column caption? For example, based on who the user is, I'd like to change a column caption from "Day" to "Night".

Bob Cergol
17-Nov-2016, 11:18 AM
A user profile alias works in a dyn-view -- but that seems an expensive use given only 10 alias values are available per user. I know of no other way to do this except perhaps with some complex javascript in the report design rules tab.
10429

Alias values can be used in numerous places, including connection strings and style sheets.

Bob

Michael Macliver
20-Nov-2016, 11:25 PM
Hi Bob,

You're right, using up an alias for this is expensive, but if there's no other way to achieve it then its a route we must consider.

I was hoping that you could set the column caption in the data dictionary to @alias and it would all flow through. I've tried this but sadly it doesn't work. Dynamically changing the dyn-view column name itself is not going to work. Once you define a report, if you change the alias and hence the column name, the report just generates an error because the old column no longer exists.

Bob Cergol
21-Nov-2016, 09:29 AM
Yeah, it makes sense captioning the column name in the data source would break the report design because its metadata would be referencing the underlying column names.

Naming of columns wasn't conceived to be dynamic based on users. Hmmmm.....

Surely there is a limited number of alternative column names you have in mind for the same data. Can you create multiple versions of a given report with different column captions in each report and call the appropriate one based on your application's user?

I guess there is a way to replace the caption name at runtime using .js in the rule script. I'll see what I can find.

Bob

Michael Macliver
21-Nov-2016, 09:29 PM
I appreciate the ideas, but duplicating reports because a column label needs to change is not something I would want to undertake from a support perspective. Maybe if it was a one off for a single client.

In reality however it's not as simple as that. In this case we have two sales groups that can be named. What their called is up to the end user, so ultimately there could be an unlimited number of names.

js might be the way to go. Do aliases get interpreted in the rule script page?

Bob Cergol
22-Nov-2016, 11:04 PM
User profile @Alias values are not resolved on the rule script page.
There are some reserved words/tags that are interpreted, such as @DAI_CAP_FLT_[[Filter_Field_Name]] that can be used to generate a dynamic report title using, for example:
<reportTitle>Sales Report for the period: @DAI_CAP_FLT_[[DateFromfilterField]] - @DAI_CAP_FLT_[[DateToFilterField]]</reportTitle>

The revisions / changes documentation also has this note on page 14: "Using the @DAI_CAP_FLT_[[filter_fields]] syntax – selected filter values can be included in column captions on reports." (I haven't tried it.)

Bob