Unable to use Context Parameters in report parameter drop-down query

JA A asked on March 20, 2014 12:33

I am attempting to populate a drop-down list of site-specific values using the @CMSContextCurrentSiteName context parameter in the query, and when I run the report an exception is occurring when the form is loading. To simplify the query and test, I have scaled the query back to something very simple. Is it possible to use context parameters in a query to populate a drop-down list?

Query: SELECT S.SiteID, S.SiteName FROM CMS_Site S WHERE S.SiteID = @CMSContextCurrentSiteID

Exception Message: [Error loading the FormControl ''] [DataConnection.HandleError]: Query: SELECT S.SiteID, S.SiteName FROM CMS_Site S WHERE S.SiteID = @CMSContextCurrentSiteID: caused exception: Must declare the scalar variable "@CMSContextCurrentSiteID".

Recent Answers


Brenden Kehren answered on March 20, 2014 13:33 (last edited on December 10, 2019 02:30)

You need to define that report in the parameters of the report itself. I'm assuming you're using the Kentico Report module, is that correct? You then set the default value for it in there to a macro {%CMSContext.CurrentSiteName|(identity)GlobalAdministrator%} Then you reference the parameter by the code name you gave it in your SQL query like you've done already.

1 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.