【问题标题】:IBM Cognos Report Studio: Value prompt default selection from prompt "default text" parameterIBM Cognos Report Studio:提示“默认文本”参数中的值提示默认选择
【发布时间】:2013-11-28 13:07:24
【问题描述】:

我有一个引用参数“Year_Parameter”的值提示,以及一个包含一列(数据项表达式)的列表,它以这种方式引用与值提示相同的参数:

#prompt('Year_Parameter')#

值提示有一些静态选择:2011、2012 和 2013。 因此,当我运行我的报表,并在显示报表页面之前弹出的提示页面中输入 2012 时,在显示报表页面时,已自动从其选项列表中的值提示中选择了 2012。

此外,如果我将 2012 放在默认选择列表中,则不会显示任何提示页面,并且现在在显示报告时也会自动选择 2012 作为值提示。

但是,如果我从默认选择列表中删除 2012,并将我的数据项表达式更改为以下任一表达式:

#prompt('Year_Parameter', 'token', '2012')#
#prompt('Year_Parameter', 'token', 2012)#
#prompt('Year_Parameter', 'string', 2012)#
#prompt('Year_Parameter', 'string', '2012')#

... 没有弹出提示页面,就像将 2012 指定为默认选择时一样,但没有自动为值提示选择值。值提示显示其默认标题文本:参数名称 - Year_Parameter"。

记住提示函数定义:

prompt ( prompt_name , datatype , defaultText , text , queryItem , 尾随文本)

任何人都知道为什么会发生这种情况,更重要的是如何通过在数据项表达式中指定值提示来选择默认选择的解决方案?

是不是因为prompt()宏只尝试获取参数'Year_Parameter'的值,而本身并没有给参数填充值?该参数必须由某个值提示给出(在提示页面上或嵌入在报表页面中)。

因此,提示函数的 defaultText 参数永远不会填充参数本身,而是在参数没有(有效)值的情况下由这个特定的提示函数返回?

非常感谢您的任何意见!

编辑:找到关于如何为参数动态分配默认值的说明。

http://cognosknowhow.blogspot.no/2013/04/how-to-dynamically-set-up-default-value.html

最终:我最终使用了以下 Javascript 来动态选择值提示并更新报告:

<script type="text/javascript">
// This function updates the report dynamically for the current year
// The function is wrapped inside a setTimeout call in order to avoid an error caused by too frequent requests
setTimeout(function updatePrompt() {
    var oCR = cognos.Report.getReport("_THIS_");
    var yearPrompt = oCR.prompt.getControlByName("YearPrompt");
    var selectedValue = yearPrompt.getValues()[0];

    if (typeof selectedValue === "undefined") {
        currentYear = new Date().getFullYear();
        yearPrompt.setValues([{'use':currentYear}]);
        // Update report
        oCR.sendRequest(cognos.Report.Action.FINISH);
    }
}, 50);
</script>

【问题讨论】:

    标签: cognos cognos-bi cognos-10


    【解决方案1】:

    正如Skovly所说,提示宏无法将值填充到参数中。从提供的链接中,我会选择 javascipt(第一个选项),但请记住 IBM 将语法从一个版本更改为另一个版本。

    (我还不知道如何在答案上发布 cmets,否则我会将其附加到上一个答案中,以强化您无法使用提示宏做您想做的事情的观点)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-01-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-02-04
      • 2022-06-30
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多