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

Custom Control JavaScript to hide the prompt page

Started by Ravisha, 17 Nov 2020 11:19:44 AM

Previous topic - Next topic

Ravisha

Hi Cognoise,

>> Environment : CA 11.1.6 <<

In a few reports with 'Run with full interactivity' set to 'No', we are using a JavaScript (in a standard HTML Item) to hide the first prompt page which contains two value prompts with a default start date and end date. At the run time, the first prompt page will not be displayed and the JavaScript in this page will resolve to setTimeout("promptButtonNext();",1000) thereby passing the default date values (start date and end date) onto the second prompt page which contains two date prompts 'Start Date' and 'End Date'. The value prompts in the first prompt page and the date prompts in the seconds prompt page share the same parameter names 'Start_Date' and 'End_Date' We would like to convert this to leverage custom control. Could someone please assist with the steps and the JavaScript code.

Thanks in advance!

dougp


Ravisha

Thanks for your reply, Dougp.

Just want to make sure if the JavaScript 'PromptAutoFinish.js' resolves to 'Next' (next prompt page) but not 'Finish'. Could you please elaborate on the steps? Do I have to add this custom control in first prompt page or the second prompt page? Would I have to fill in any values in the 'Configuration' property of the custom control?

Thanks you!


oscarca

Hi,

I created a custom control with the below code:

define( function() {
"use strict";

document.head.appendChild( document.createElement( "STYLE" ) ).innerHTML =
"TABLE.clsViewerProgress," +
"TABLE.clsViewerProgress *" +
"{" +
"visibility: hidden !important;" +
"}";

function Control()
{
};

Control.prototype.show = function( oControlHost )
{
var fDefaultSeconds = 0.05;
var fSeconds = ( oControlHost.configuration ? oControlHost.configuration.Seconds : fDefaultSeconds ) || fDefaultSeconds;
this.m_iTimer = setTimeout( oControlHost.finish.bind( oControlHost ), Math.round( fSeconds * 1000 ) );
};

Control.prototype.hide = function( oControlHost )
{
this.cancelRefreshTimer();
};

Control.prototype.destroy = function( oControlHost )
{
this.cancelRefreshTimer();
};

Control.prototype.getParameters = function( oControlHost )
{
// WARNING: Do not remove this method.
// Pages that don't contain prompt controls are cached by the viewer. The existence of a getParameters
// is used as the indicator that the custom control is prompt-like and will prevent caching.
};

Control.prototype.cancelRefreshTimer = function()
{
if ( this.m_iTimer )
{
clearTimeout( this.m_iTimer );
this.m_iTimer = null;
}
};

return Control;
});


Place the custom control object and the prompt in a table on the first prompt page. Make sure you have set a default selection on your prompt. On the custom control set UI type: None and leave configuration blank. Hide the table (set visibility to no) and delete prompt header and footer to make the prompt page completely white.

//Oscar

dougp

QuoteJust want to make sure if the JavaScript 'PromptAutoFinish.js' resolves to 'Next' (next prompt page) but not 'Finish'. Could you please elaborate on the steps? Do I have to add this custom control in first prompt page or the second prompt page? Would I have to fill in any values in the 'Configuration' property of the custom control?

It's configurable.  If you're not comfortable reading JavaScript, you probably shouldn't be using it in a production environment.

If you don't like the documentation, improve it and submit a pull request.

oscarca

Really nice of you to share your work at githup Dougp. You truly got some great stuff there.

dougp

Thanks for the compliment.  I updated my previous post to be clear about what I was responding to.

Ravisha

Quote from: oscarca on 18 Nov 2020 12:56:23 AM
Hi,

I created a custom control with the below code:

define( function() {
"use strict";

document.head.appendChild( document.createElement( "STYLE" ) ).innerHTML =
"TABLE.clsViewerProgress," +
"TABLE.clsViewerProgress *" +
"{" +
"visibility: hidden !important;" +
"}";

function Control()
{
};

Control.prototype.show = function( oControlHost )
{
var fDefaultSeconds = 0.05;
var fSeconds = ( oControlHost.configuration ? oControlHost.configuration.Seconds : fDefaultSeconds ) || fDefaultSeconds;
this.m_iTimer = setTimeout( oControlHost.finish.bind( oControlHost ), Math.round( fSeconds * 1000 ) );
};

Control.prototype.hide = function( oControlHost )
{
this.cancelRefreshTimer();
};

Control.prototype.destroy = function( oControlHost )
{
this.cancelRefreshTimer();
};

Control.prototype.getParameters = function( oControlHost )
{
// WARNING: Do not remove this method.
// Pages that don't contain prompt controls are cached by the viewer. The existence of a getParameters
// is used as the indicator that the custom control is prompt-like and will prevent caching.
};

Control.prototype.cancelRefreshTimer = function()
{
if ( this.m_iTimer )
{
clearTimeout( this.m_iTimer );
this.m_iTimer = null;
}
};

return Control;
});


Place the custom control object and the prompt in a table on the first prompt page. Make sure you have set a default selection on your prompt. On the custom control set UI type: None and leave configuration blank. Hide the table (set visibility to no) and delete prompt header and footer to make the prompt page completely white.

//Oscar

Thanks a ton for sharing the script and the steps. Very kind of you!

My apologies for missing an important thing to mention is that we would want the script to capture the first date value (not the header text of the prompts) from the both value (drop down) prompts (start Date and End Date) and pass it onto the date prompts in the second prompt page. Having said that, it would be greatly appreciated if you could please assist or amend/revise the script? I'm sorry, if I know how to do it, I'd do it myself.

Value-Prompts" border="0

Ravisha

Quote from: dougp on 18 Nov 2020 10:07:19 AM
It's configurable.  If you're not comfortable reading JavaScript, you probably shouldn't be using it in a production environment.

If you don't like the documentation, improve it and submit a pull request.

I read your PromptAutoFinish script; hence the question I asked. However, it's my inability to amend the code per my needs. You have done a great job with those scripts and very kind of you to share the knowledge with others. Thank you, sir!

dougp

Quotewe would want the script to capture the first date value (not the header text of the prompts) from the both value (drop down) prompts (start Date and End Date)

ReportSpecifications/Parameter Value Automation.txt contains a report spec demonstrating how to do this.

Setting Multi-select = Yes gets rid of the header.  Since there is no user interaction (the prompt will not be visible and only the script will be selecting the value) there is no danger of too many values being selected.

If you only want the first value, there should only be one value in the prompt.  I assume your prompt is fed by a query.  Craft the query to return only the value you want.

Ravisha

#10
@oscarca - I have tried the steps which you have suggested and based on Dougp's suggestion I changed the values prompts to multi-select. However, it isn't working as we expected. The first prompt page doesn't resolve to the second prompt page nor is it passing the parameter values (Start Date and End Date) to the Date prompts in the second prompt page. Instead, upon running the report, it renders the report page directly. Please assist.

I'm not sure why I get an error "Cannot access attachments upload path!" when I try to upload an attachment to my reply. So I've uploaded the report XML which can be downloaded by accessing the link below

https://gofile.io/d/ikK5wS

Cognoise-Upload-Error" border="0


@Dougp - I crafted the query to return single value in each value prompt (in the first prompt page). I looked into your 'Parameter Value Automation' report xml and I've found that first prompt page's page module is using Prompt.js script which is a very lengthy script to maintain (looking for something short that would do the job). However, in my case, I've tried your solution to no avail. Please advise.

Thank you for your support!

Ravisha

Could someone please share any thoughts/ideas?

dougp

QuotePrompt.js script which is a very lengthy script to maintain

If you want to maintain a plethora of "simple" scripts that all serve one basic purpose, that's your call.  I didn't find any of this simple when I started.  That's why I decided to put it all in one place.

Good luck.