Hello All,
We are facing an issue where we have upgraded to Cog11.0.9 version
There are certain Htms tags which has Java Script Code embedded in in at the prompt page of the Reports:
In Cognos New versions it stikes out the html functionlity in the Reprts
Is there any way we can Configure Java Scrips in new version of Cognos
i heard there is some new feature as Custom Control which helps to integrate :
Request your inputs on above issue:
Regards
Cognos BI
Quote from: BIAnalytics on 30 Jan 2018 10:46:12 PM
Hello All,
We are facing an issue where we have upgraded to Cog11.0.9 version
There are certain Htms tags which has Java Script Code embedded in in at the prompt page of the Reports:
In Cognos New versions it stikes out the html functionlity in the Reprts
Is there any way we can Configure Java Scrips in new version of Cognos
i heard there is some new feature as Custom Control which helps to integrate :
Request your inputs on above issue:
Regards
Cognos BI
Are you running your reports with the Full Interactivity property set to Yes or to No?
If No, then the report should run using the non-interactive viewer, and the javascript you embedded into your page should work as it did in C10 (provided you are using code that utilises the Prompt API).
If Yes, then the javascript embedded into your page is stripped out, so you need to code your javascript in files that are stored somewhere your browser (and everyone else's browser) can access them, and reference the code using Custom Control objects from the toolbox.
https://www.ibm.com/support/knowledgecenter/en/SSEP7J_11.0.0/com.ibm.swg.ba.cognos.ug_cr_rptstd.doc/t_rpting_add_javascrpt.html
Cheers!
MF.
thanks for the revert:
On the Full Interactivity to yes: it produces the below error:
"HTML report output is not well formed. If your report uses "HTML Item" elements ensure that they result in well-formed HTML".
when set to No:
Report is running but layout of Expand/Collapse feature is not showing properly:
Missing "+" and "-" images in "tree" prompt
As per my understanding, we need to configure Java Script files using Custom Control:
Below are some of my queries:
--> What will be path for Module path:
--> is the Configuration property Mandatory to be defined:?
--> Can we use the existing Java Script Code or we need to build the code again..?
Thanks
I don't ever use JavaScript in my reports, so I can't answer your specific questions, sorry. I suspect that you will need to share the code you are using for anyone to be able to help you, though. Otherwise, it's going to be very difficult for people to know why you are having issues.
Cheers!
MF.
Quote from: BIAnalytics on 31 Jan 2018 03:26:26 AM
thanks for the revert:
On the Full Interactivity to yes: it produces the below error:
"HTML report output is not well formed. If your report uses "HTML Item" elements ensure that they result in well-formed HTML".
when set to No:
Report is running but layout of Expand/Collapse feature is not showing properly:
Missing "+" and "-" images in "tree" prompt
As per my understanding, we need to configure Java Script files using Custom Control:
Below are some of my queries:
--> What will be path for Module path:
--> is the Configuration property Mandatory to be defined:?
--> Can we use the existing Java Script Code or we need to build the code again..?
Thanks
Hi
As far as I understand from the sample proof of concept we created , you need configuration settings only when you need some inputs to JavaScript methods. You can copy your existing JavaScript methods into a file and use that in the module path. Module path is relative to bi/ folder and you can place the js files anywhere accessible in the installation folders.
Thanks
Kiran
Sent from my ZUK Z2132 using Tapatalk
Quote from: BIAnalytics on 31 Jan 2018 03:26:26 AM
when set to No:
Report is running but layout of Expand/Collapse feature is not showing properly:
Missing "+" and "-" images in "tree" prompt
This could be caused by the fact that stuff that used to be under webcontent/ is now searched from webcontent/bi/.
QuoteAs per my understanding, we need to configure Java Script files using Custom Control:
Review the information IBM posted on their community blog site. The second article here (Rachel Su) includes documentation and samples. (Look for the link to Technical Documentation near the bottom of the article.)
https://www.ibm.com/communities/analytics/cognos-analytics-blog/video-overview-scriptable-reports-11-0-4/ (https://www.ibm.com/communities/analytics/cognos-analytics-blog/video-overview-scriptable-reports-11-0-4/)
https://www.ibm.com/communities/analytics/cognos-analytics-blog/javascript-support-in-interactive-viewer/ (https://www.ibm.com/communities/analytics/cognos-analytics-blog/javascript-support-in-interactive-viewer/)
QuoteWhat will be path for Module path:
Whatever you want. I put my custom JavaScript files at \\cognosservername\wwwroot\CognosScripts\ so the Module path property is
/CognosScripts/filename.js
Quoteis the Configuration property Mandatory to be defined:?
That is completely up to you. It depends on how you design the functionality implemented in your JavaScript file. For my scripts that can use a configuration (allowing the user to customize the output), I include defaults in the code so that no configuration is required.
QuoteCan we use the existing Java Script Code or we need to build the code again..?
You can use it, but you'll need to massage it into AMD (https://github.com/amdjs/amdjs-api/wiki/AMD) (Asynchronous Module Definition) -- specifically to be compatible with RequireJS (http://requirejs.org/). Look at the samples from Rachel's blog post.
The only report we are using html in (on version 11.0.6 with full interactivity set to no) is to make an optional in report date prompt empty/null by default instead of the current date.
Can anyone tell me if 11.0.9 will allow the date to have a null default or will I have to deal with moving the javascript and using a custom control?
Thanks in advance.
You can use the following code to null out the date prompt:
define( [
], function( ) {
"use strict";
function clearDatePrompt(){};
clearDatePrompt.prototype.initialize = function( oControlHost, fnDoneInitializing )
{
var o = oControlHost.configuration
, secondaryRun = sessionStorage.getItem(this.ctrlFrom+'secondaryRunClearPrompt');
;
this.ctrl = o["prompt"]
if(!secondaryRun) {oControlHost.page.getControlByName(this.ctrl).element.getElementsByTagName('input')[0].value="";
oControlHost.page.getControlByName(this.ctrl).element.getElementsByTagName('input')[0].onchange()}
sessionStorage.setItem(this.ctrl+'secondaryRunClearPrompt',1);
fnDoneInitializing();
};
return clearDatePrompt;
});
I put in some code to prevent it from running after the first instance, but you can massage it to meet your needs.
Hi Paul,
I am trying to compare start date/time and end Date/Time using Date/Time Prompt and prevent users from selecting start dates/Time AFTER the end date/Time, or vice versa Using Cognos 11.0.6 using custom control.Can you please help me with the javascript using custom control.
Hi Paul,
I am trying to compare start date/time and end Date/Time using Date/Time Prompt and prevent users from selecting start dates/Time AFTER the end date/Time, or vice versa Using Cognos 11.0.6 using custom control.Can you please help me with the javascript using custom control.
I looked into the below link but unable to add the time and i am poor at javascript
http://www.pmsquare.com/main/blog/cognos-analytics-custom-javascript-date-prompts-datasets/
I've updated the script to support datetime prompts.
Try setting dynStartDate to '2018-01-01 13:30' (the quotes there are important, so the config might look like:
{
"fromPrompt": "startDate",
"toPrompt": "endDate",
"dynStartDate": "'2018-01-01 13:23'",
"dynEndDate": "'2018-02-02'"
}
Thanks Paul for the updated Javascript!!
I ran the report with the updated script - when i select the start date/time greater than the end date/time on the prompt page it gave a message saying that "Start date cannot be later than the end date" but it didn't allow me to click on "OK" button(and also it didn't set the dynamic start date which is on the configuration 2018-01-01 13:23) even if i changed the start date/time less than end Date/time it gave a error message saying that
"Script error https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js " 0
I had a question that instead of setting dynStartDate to '2018-01-01 13:30' and "dynEndDate": "'2018-02-02'" Can i use dynStartDate to
moment().subtract(1,'day') and "dynEndDate" to moment().add(1,'day') and add dynamic time as well(not sure about the format)?
Thanks
Moni.
I'm not entirely certain why you're getting that error. Try saving the report and running from connection.
You absolutely can use dynamic time functions.
moment().add(1,'d').add(32,'minutes').subtract(1,'h')
you could also do
moment().add({days:1,minutes:32,hours:-1})
Take a look at the moment documentation here: https://momentjs.com/docs/#/manipulating/
Any of those functions should work.
Thanks Paul for the update.
I Saved the report and ran from cognos connection (11.0.6) but i am getting below error when i used developers tool debugger
Uncaught Error: Bootstrap's JavaScript requires jQuery at bootstrap.min.js:6
"https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"
and got this error when i set start date/time is greater than end date /time
Uncaught TypeError: $(...).popover is not a function
at _PL5.fromVal (FromToDateValidation.js:153)
at _PL5._3BA (_PL5.js:6)
at _PL5._NTG (_PL5.js:6)
at _IQ2._5N (_IQ2.js:6)
at _CGI._3W8._5N (_3W8_async.js:6)
at _792._PN5 (_792.js:6)
at _792._XRF (_792.js:6)
at _792._OY8 (_792.js:6)
at _792._QIE (_792.js:6)
any idea?
Thanks
Moni
Last try.
I've updated the code to use bootstrap v4, but that requires poppover.js (which you can download here (https://popper.js.org/)) be placed under webcontents/bi/pat/
The previous version of bootstrap kept popping up an error because it was trying to update the popover after it was destroyed. This version handles it more gracefully.
Thanks Paul...Updated script is working and no errors but the only thing is it is disabling the finish button and not able to run the report other than that every thing works great.
Ex: if i select start date/time greater than end date/time then it sets the dynamic date but disabling the ok button to run even if i changed to correct dates.
Thanks
Moni.
interesting. it looks like having an empty validator will cause datetime prompts to validate to false, while other prompts succeed.
Easy fix, change setValidator(function(){}) to setValidator(function(){return true})
(see attached)
Hi Paul,
I updated the script with setValidator(function(){return true}) and now when i run the report it shows the prompt page and when i try to select it is executing without doing anything and not giving option to select or change the datetime .
Thanks
Moni.
I'm not sure what to say, it is working fine on my laptop. Did you try the version I attached to the post? Also, try clearing your browser cache.
Thank you so much Paul!!.I cleared my browser cookies and it is working great.
Thank you,
Moni.
Hi Paul ,
Had an issue with date/Time prompt custom control -when i set below dates in configuration and hit the finish button but is shows paramdisplayvalue for start and end datetime prompt as Current day.
{
"fromPrompt": "startDate1",
"toPrompt": "endDate1",
"dynStartDate": "moment().subtract(1,'day')",
"dynEndDate": "moment().add(1,'day')"
}
Thanks
Moni
Hi Paul,
Any idea on above issue? Any help is appreciated .
Thanks
Moni.
Are the values changing in the prompt? I'm using sessionStorage to determine if the date should be adjusted. After the first run of the page, the script remembers not to update the prompt. This prevents the script from replacing an item the user selects.
I've added better support for time prompts. It now determines the type of prompt, and formats the datetime correctly. This might also fix the problem you're seeing.
Hi Paul,
When i run the report i get the prompt page with start date as Mar 5th and end date as March 7th(as per "dynStartDate": "moment().subtract(1,'day')",
"dynEndDate": "moment().add(1,'day')")......... then i clicked Finish prompt button with out making any change - but It showed March 6th 12:00AM as start date and March 6th as end date too on the report Page using (ParamDisplayValue('')).I updated the script too but the problem still there.
But after running the report - if i made any changes to the prompts then clicked on the finish button - it is working perfectly but if i didn't make any change to the prompts after running the report with default values then it is not working.
One more issue i found was if start date/time was set to Feb 22nd and end date/time was set to March 21st - If i want to change the start date/time to March 20th (I clicked on the calendar of start date/time and changed the month to March then it is saying start date is greater than end date because earlier it is set to Feb 22nd i.e day 22nd is greater than 21st ....is it normal behavior of the date/time prompt)
Thanks
Moni.
Which version are you running? It sounds like a bug that was squashed in the latest release.
Hi Paul,
We are using cognos 11.0.8 .I tried both 11.0.6 and 11.0.8 as well.
Is it working on your system and which version?
Thanks
Moni
Quote from: CognosPaul on 15 Feb 2018 10:38:19 PM
Last try.
I've updated the code to use bootstrap v4, but that requires poppover.js (which you can download here (https://popper.js.org/)) be placed under webcontents/bi/pat/
The previous version of bootstrap kept popping up an error because it was trying to update the popover after it was destroyed. This version handles it more gracefully.
Hi Paul,
I kept getting popover error from the previous version and I want to try your version with bootstrap v4. Could you attach it again or kindly send me an e-mail to robert.aprlynt@gmail.com
Thanks in advance