简体   繁体   English

如何在Cognos Bi中的值提示或文本提示中将最近使用的参数值设置为“默认”

[英]How to set most recently used parameter value as Default in value prompt or text prompt in Cognos Bi

I am using Cognos Bi 10.2.2 version. 我正在使用Cognos Bi 10.2.2版本。

I have created a prompt page for a parameter with value prompt.I am using the parameter as "Term_Code" which containing values such as 201410,201420,201510... and I will select the Parameter value "201420" for the first time while running the report. 我为带有值提示的参数创建了一个提示页面。我将参数用作“ Term_Code”,其中包含诸如201410,201420,201510...值,并且我将首次选择参数值“ 201420”运行报告。 When i run my report again in future i must get default value as 201420 which is Most recently used parameter Value. 当我将来再次运行报表时,我必须获取默认值201420,即最近使用的参数值。 Can Anyone Know it, 任何人都可以知道

How to get Most recently used parameter value as the default value in value Prompt . 如何获取最近使用的参数值作为值Prompt中的默认值 Please help me. 请帮我。

Thanks in advance. 提前致谢。

You can create a cookie to set its value to what the user last selected. 您可以创建一个cookie,以将其值设置为用户上一次选择的值。 The way I've done this is to drag an HTML Item to after the prompt then inside the HTML element, you can place the JavaScript to take care of creating the cookie and setting its value. 我这样做的方法是将HTML项目拖到提示后,然后放在HTML元素内,您可以放置​​JavaScript来创建cookie并设置其值。

Here is the JavaScript I used: 这是我使用的JavaScript:

<script>

function createCookie(name,value,days) {
    if (days) {
        var date = new Date();
        date.setTime(date.getTime()+(days*24*60*60*1000));
        var expires = "; expires="+date.toGMTString();
    }
    else var expires = "";
    document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');
    for(var i=0;i < ca.length;i++) {
        var c = ca[i];
        while (c.charAt(0)==' ') c = c.substring(1,c.length);
        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
    }
    return null;
}

function subtractDay ()
{
var dtToday = new Date();
var dtYesterday = new Date( dtToday - 86400000 ); // 86400000 = 24 hours * 60 (minutes per hour) * 60 (seconds per minute) * 1000 (milliseconds per second)
var strYesterday = [dtYesterday.getUTCFullYear(), dtYesterday.getMonth()+1, dtYesterday.getDate()].join("-");
return strYesterday;
}



var x = readCookie('MyCookie');
while (x != 'Value'){
    pickerControlpDatePicked.setValue(subtractDay() );
    createCookie('MyCookie','Value',0);
    x = readCookie('MyCookie');

}
</script> 

The function pickerControlpDatePicked get the date selected (that was my use case). 函数pickerControlpDatePicked获取选择的日期(这是我的用例)。 I think there should be a similar function for String 我认为String应该有一个类似的功能

this is just a suggestion of a possible solution. 这只是可能解决方案的建议。

In Framework Manager you can make a query subject linked to a stored procedure. 在Framework Manager中,您可以使查询主题链接到存储过程。 Every time the report is executed, the parameter Team_Code would be passed to the query linked to the stored procedure, and the stored procedure would save its value in a database table. 每次执行该报告时,都会将参数Team_Code传递给链接到该存储过程的查询,并且该存储过程会将其值保存在数据库表中。

The next time the report is executed, the prompt page would query the table of the saved parameters for the last parameter saved, and using the JavaScript Prompt API would set this value as the default value of the prompt control in the prompt page. 下次执行该报告时,提示页面将查询已保存参数的表以获取最后保存的参数,并且使用JavaScript Prompt API将此值设置为提示页面中提示控件的默认值。

I hope this helps, good luck! 希望对您有帮助,祝您好运!

Cognos is not designed to store information about prompt choices, with the one exception of report views. 除报表视图外,Cognos并非旨在存储有关提示选择的信息。 However, this won't help you as report view prompt values are not dynamic. 但是,这不会帮助您,因为报表视图提示值不是动态的。 You set a fixed value and it keeps that value until you change it manually. 您设置了一个固定值,并保持该值,直到您手动更改它为止。

What I would do is setup a small Web service. 我要做的是设置一个小型Web服务。 This would be a Web page whose purpose is to receive requests via Web URL and return information or perform some action. 这将是一个网页,其目的是通过Web URL接收请求并返回信息或执行某些操作。 A single page could be created to: 可以创建一个页面以:

  1. Receive a new value and store it in a database, or even a cookie 接收新值并将其存储在数据库中,甚至存储在cookie中
  2. Retrieve a value from the database/cookie and return it to the requester 从数据库/ cookie中检索一个值并将其返回给请求者

The Cognos prompt page would have JavaScript that fired when the prompt page is first generated to retrieve the stored value via the Web service and set the prompt value to the previous selection. Cognos提示页面将具有在首次生成提示页面时触发的JavaScript,以通过Web服务检索存储的值并将提示值设置为先前的选择。 There would also be JavaScript that fired when the user selected a new value which would send the choice to the Web service for storage. 当用户选择一个新值时,还将触发JavaScript,该新值会将选择发送到Web服务进行存储。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM