gpt4 book ai didi

cognos - IBM Cognos Report Studio : Value prompt default selection from prompt "default text" parameter

转载 作者:行者123 更新时间:2023-12-03 07:38:46 27 4
gpt4 key购买 nike

我有一个引用参数“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 , trailing_text )

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

是否是因为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>

最佳答案

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

(我还不知道如何对答案发表评论,否则我会将其附加到上一个答案中,以强化您无法使用提示宏执行您想要的操作的观点)。

关于cognos - IBM Cognos Report Studio : Value prompt default selection from prompt "default text" parameter,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19996007/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com