Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Prompt Validation in Report Studtio

Status
Not open for further replies.

rm1234

MIS
Jul 24, 2005
38
0
0
EU
Can anyone help me in how to validate prompts in Report Studion and return error message.

Example
1) 2 date prompts and to check if one is greater than the other

2) Validate an user input against a master table (Oracle DB)and return error if value does not exist
 
Hi,

As far as the 1st question goes, one way is to insert a HTML item on your prompt page using some (or all) of the following code. This code in addition for checking date sequence also provide default values for the 2 dates.

<script>
var cntlName;
function right(str, n){
if (n <= 0)
return "";
else if (n > String(str).length)
return str;
else {
var iLen = String(str).length;
return String(str).substring(iLen, iLen - n);
}
}
function customCheckPage(){
var par1;
var par2;
for( var i=0; i<preProcessControlArray.length; i++){
cntlName = eval(preProcessControlArray);
if ( cntlName.m_oSubmit.name.toLowerCase() == 'p_fromdate' ){
eval('pickerControl' + cntlName.m_sRef + '.lostFocus()');
par1 = cntlName.m_oForm.value;
}
if ( cntlName.m_oSubmit.name.toLowerCase() == 'p_thrudate' ){
eval('pickerControl' + cntlName.m_sRef + '.lostFocus()');
par2 = cntlName.m_oForm.value;
}
}
if (par1<=par2)
promptButtonFinish();
else
alert('FROM DATE parameter must be smaller than or equal to TO DATE parameter!');
}
for( var i=0; i<pageNavigationObserverArray.length; i++){
cntlName = eval( pageNavigationObserverArray );
if(cntlName.m_oParent.onclick.toString().indexOf('promptButtonFinish()')>0 ){
cntlName.m_oParent.onclick = customCheckPage;
}
}
for( var i=0; i<preProcessControlArray.length; i++){
cntlName = eval(preProcessControlArray);
dw = new Date();
dt = new Date( dw - 1*86400000);
df = new Date( dw - 7*86400000);
if (cntlName.m_oSubmit.name.toLowerCase() == 'p_fromdate' ){
cntlName.m_oEditBox.value = df.getFullYear()
+ '-' + right('0'+(1+df.getMonth()),2)
+ '-' + right('0'+df.getDate(),2);
eval('pickerControl' + cntlName.m_sRef + '.lostFocus()');
}
if (cntlName.m_oSubmit.name.toLowerCase() == 'p_thrudate' ){
cntlName.m_oEditBox.value = dt.getFullYear()
+ '-' + right('0'+(1+dt.getMonth()),2)
+ '-' + right('0'+dt.getDate(),2);
eval('pickerControl' + cntlName.m_sRef + '.lostFocus()');
}
}
</script>

The Javascript above references your 2 dates as 'p_' plus your actual prompt names. In this example my dates on the prompt page are 'fromdate' & 'thrudate' and referenced in the script as 'p_fromdate' & 'p_thrudate'

See Cognos help at ...


IMPORTANT: There is a bug in this COGNOS tutorial but the general idea is sound.

Hope this helps.

Rich
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top