Rob M
Rob M

Reputation: 301

Kentico report - reference field A value from dependent field B

I am creating a report (in Kentico 10) which has 'cascading' parameters. In order to describe my problem, it is sufficient to mention the following report parameters:

  1. Region (North America, Asia Pacific, etc.) - a dropdown driven by a SQL query
  2. Country (US, CA, MX, DE, FR, etc.) - a dropdown driven by a SQL query, limited by the value of the Region field

When viewing the report, I would like for the value chosen in the Region field to affect the contents of the Country field. The SQL code is not a problem, but actually getting the value of the Country field is.

I have configured the Region field with 'Has depending fields' checked. I have configured the Country field with 'Depends on another field' checked. In the WHERE clause of its SQL query, I reference '{%Region.Value%}'. (per this article) This does not work. Upon further investigation, I found that the result of {%Region.Value%} is "RegionName", which is the field name specified in the Region field's 'Value column' setting.

How do I access the selected value in the Region dropdown, rather than the name of the field whose value is displayed in that dropdown?

A subsequent question would be: After choosing a Region, the page posts back and my Region choice is lost. How do I make it stick?

(Also, it is not acceptable to replace the SQL-driven dropdown with a static list of regions. This needs to be SQL driven, as there are other dependent fields whose possible values are not static.)

Upvotes: 0

Views: 169

Answers (1)

JanH
JanH

Reputation: 519

Only the value part is passed to your depending field, so if your region SQL query looks like this:

SELECT RegionID, RegionName from Custom_Region

The RegionID is the value of the {%Region.Value%} macro. If you need to pass the region Name the query would look like this:

SELECT RegionName, RegionName from Custom_Region

Upvotes: 1

Related Questions