If you are unable to create a new account, please email support@bspsoftware.com

 

News:

MetaManager - Administrative Tools for IBM Cognos
Pricing starting at $2,100
Download Now    Learn More

Main Menu

default dynamic prompt values - the latest date

Started by bbtresoo, 11 Apr 2014 09:06:39 AM

Previous topic - Next topic

bbtresoo

Hi guys

Maybe someone can help me right here. I've been struggling for a while to set a defaut value dynamically. I don't undestand because i'm applying a javascript code I picked on youtube which matchs my problem but no changes at all .I don't know if it's a matter o version or not.
below is the javascript code I applied

<script type="text/javascript">
var fW=(typeof getFormWarpRequest=="function" ? getFormWarpRequest() : document.forms["formWarpRequest"]);
if (fW)
{
  if(fW._oLstChoicesMyList.length>=1)
{
  fW._oLstChoicesMyList.selectedIndex = 0;
}
}
</script>


is it a way in cognos to know if my javascript code is valid or not? Just to add i'm using 10.2 version
Thank you for your feedback

hwmohrmann

I never got any of the javascript code that I found on the web to work, don't have any idea what I missed.
So I just came up with my own kludge.
Create an 'HTML' box to the right of the Date Range Prompt.
Populate the box with:

<script>
function doit() {
  var elements = document.getElementsByTagName('input')
  for(var i=0; i<elements.length; i++) {
    var input = elements;
    var header = input.id.substring(0,8);
    if(header == 'txtDateF') input.value = 'Select From Date';
    if(header == 'txtDateT') input.value = 'Select To Date';
  }
}
doit();
</script>

The main problem is that the date text fields have a random extension to the name every time the report is run, like:
txtDateF_N4346d820x443ade78RS
txtDateT_N4346d820x443ade78RS
The finding by 'input' seemed to be the only reliable way to find the fields.
You get back about 8 elements, two of which are the fields you want.
Two of the other fields in the list are:
_DateF_xxxxxxxxxxxxxxxxx
_DateT_xxxxxxxxxxxxxxxxx
These are the hidden values that are in the Calendar control.

I will leave it up to you on how you want to figure out what dates you want to use.



MFGF

Quote from: bbtresoo on 11 Apr 2014 09:06:39 AM
Hi guys

Maybe someone can help me right here. I've been struggling for a while to set a defaut value dynamically. I don't undestand because i'm applying a javascript code I picked on youtube which matchs my problem but no changes at all .I don't know if it's a matter o version or not.
below is the javascript code I applied

<script type="text/javascript">
var fW=(typeof getFormWarpRequest=="function" ? getFormWarpRequest() : document.forms["formWarpRequest"]);
if (fW)
{
  if(fW._oLstChoicesMyList.length>=1)
{
  fW._oLstChoicesMyList.selectedIndex = 0;
}
}
</script>


is it a way in cognos to know if my javascript code is valid or not? Just to add i'm using 10.2 version
Thank you for your feedback

I'd like nothing better than to be able to help here, but (as all my friends and acquaintances know) Javascript is my sworn arch-enemy - something I avoid at all costs on pain of death. I once dabbled with it in a post, and Lynn was so amazed she posted a reply to see if I had gone insane. :)

Hopefully someone with Javascript skills will be along shortly. In the meantime, I can recommend a healthy dose of thumb-twiddling to while away the rest of your Friday afternoon :)

MF.
Meep!

MFGF

Ah. There you go. Before I posted, even! Shame about the thumb-twiddling - now you'll never get to know how satisfying it can be :)

Cheers!

MF.
Meep!

bbtresoo

Quote from: hwmohrmann on 11 Apr 2014 10:49:13 AM
I never got any of the javascript code that I found on the web to work, don't have any idea what I missed.
So I just came up with my own kludge.
Create an 'HTML' box to the right of the Date Range Prompt.
Populate the box with:

<script>
function doit() {
  var elements = document.getElementsByTagName('input')
  for(var i=0; i<elements.length; i++) {
    var input = elements;
    var header = input.id.substring(0,8);
    if(header == 'txtDateF') input.value = 'Select From Date';
    if(header == 'txtDateT') input.value = 'Select To Date';
  }
}
doit();
</script>

The main problem is that the date text fields have a random extension to the name every time the report is run, like:
txtDateF_N4346d820x443ade78RS
txtDateT_N4346d820x443ade78RS
The finding by 'input' seemed to be the only reliable way to find the fields.
You get back about 8 elements, two of which are the fields you want.
Two of the other fields in the list are:
_DateF_xxxxxxxxxxxxxxxxx
_DateT_xxxxxxxxxxxxxxxxx
These are the hidden values that are in the Calendar control.

I will leave it up to you on how you want to figure out what dates you want to use.




tks , i tried no success, tell me something  does "txtDateF' stand for my real column name? and 'Select From Date' the name I give in the properties name (Miscellaneous). thanks for your feedback

bbtresoo

Quote from: MFGF on 11 Apr 2014 10:51:38 AM
Ah. There you go. Before I posted, even! Shame about the thumb-twiddling - now you'll never get to know how satisfying it can be :)

Cheers!

MF.

It's ok I got u lol, tks for getting back to me though. java isn't my cup of tea too but for what I want it looks like I need to pass through that beast!!!

bbtresoo

the script below highlights me the latest date as wanted but doesn't filter the list below the prompt. and if I select other dates the filter works  but the latest date stays highlighted.  after some test I found that even if the latest date is highlighted cognos considers the default value inside the prompt as null. To find out I've just made that simple condition
if (ParamDisplayValue('Param_date') is null) then('empty') else ('not empty')  and 'empty' was returned.

here's the script

<script language="javascript">

function setDefaultVaule()
{
var form = getFormWarpRequest();
form._oLstChoicesTradeDate1.options[2].selected = true;

}

setDefaultVaule()

</script>