简体   繁体   中英

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.

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. When i run my report again in future i must get default value as 201420 which is Most recently used parameter Value. Can Anyone Know it,

How to get Most recently used parameter value as the default value in value Prompt . Please help me.

Thanks in advance.

You can create a cookie to set its value to what the user last selected. 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.

Here is the JavaScript I used:

<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). I think there should be a similar function for String

this is just a suggestion of a possible solution.

In Framework Manager you can make a query subject linked to a stored procedure. 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.

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.

I hope this helps, good luck!

Cognos is not designed to store information about prompt choices, with the one exception of report views. 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. This would be a Web page whose purpose is to receive requests via Web URL and return information or perform some action. A single page could be created to:

  1. Receive a new value and store it in a database, or even a cookie
  2. Retrieve a value from the database/cookie and return it to the requester

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. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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