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

javascript function is not working in mozilla and chrome

Started by inu, 06 Jan 2017 08:14:43 AM

Previous topic - Next topic

inu

Hi Team,
I used js function for reset button, which will reset  deault values as below
<script type="text/javascript">
function clearRefresh() {

var oCR = cognos.Report.getReport("_THIS_");

var vNationality = oCR.prompt.getControlByName("From");
var vDomicile = oCR.prompt.getControlByName("To");
//  var vLevel = oCR.prompt.getControlByName("PT");
//var vFeeCategory = oCR.prompt.getControlByName("LT");
//var vCourseStage = oCR.prompt.getControlByName("Rep");
var vstateName=oCR.prompt.getControlByName("stateName");



vNationality.clearValues();
vDomicile.clearValues();
// vLevel.clearValues();
// vFeeCategory.clearValues();
//  vCourseStage.clearValues();   
vstateName.clearValues();

// Attach functions to an arbitrarily named object to mimic a namespace to ensure the name uniqueness
// Get the required prompt.
var oCR1 = cognos.Report.getReport("_THIS_");
var oP1 = oCR1.prompt.getControlByName("PT");
var oP2 = oCR1.prompt.getControlByName("LT");
var oP3= oCR1.prompt.getControlByName("Rep");




// Get the values and isolate the first value.
var allValues1 = oP1.getValues(true);
var allValues2 = oP2.getValues(true);
var allValues3 =oP3.getValues(true);

var firstValue1= allValues1[0];
var firstValue2= allValues2[0];
var firstValue3 =allValues3[0];



// Set the prompt selection to the first value.
oValues1= [firstValue1];
oValues2= [firstValue2];
oValues3= [firstValue3];

oP1.setValues(oValues1);
oP2.setValues(oValues2);
oP3.setValues(oValues3);


oCR.sendRequest (cognos.Report.Action.REPROMPT);



} </script>
<button onclick="clearRefresh();" style="width:80; height:23; backgound-color:white; border:solid 1px grey; margin:2px;">Reset</button>




In IE , its working fine, but in chrome and firefox , when i click on reset button , it redirects to cognos connection home page.

Please suggest, what is the error.


Regards,
Inam

BigChris

I don't use JS I'm afraid, so I can't help in any real sense, but I think you can open something like a debugger in your browser by pressing F12...that's extent of my knowledge though...no idea how to use what you see when you open that up.

Invisi

Have you checked if you're using ECMA script (the neutral, standardized version of Javascript) or some Microsoft flavoured variant somewhere in your code?
Few can be done on Cognos | RTFM for those who ask basic questions...

inu

Quote from: Invisi on 09 Jan 2017 02:32:03 AM
Have you checked if you're using ECMA script (the neutral, standardized version of Javascript) or some Microsoft flavoured variant somewhere in your code?

Please see the attached file , which i noted down..

BigChris


inu

Quote from: BigChris on 09 Jan 2017 05:42:56 AM
And have you tried going to https://xhr.spec.whatwrg.org/ to see what the extra help is?

I saw that, but i didnot get the point what i have to do.
Can you please specify the points. or what step should i take.
Because that javascript file is deprecated . this is not brower issue. Even in IE we cant get it works properly if we have updated browser. Right now my browser version is 8. and chrome and mozilla are update, that's the reason.
Should i raise the PMR... What kind of tool IBM has developed, its a blunder bug.
Please suggest.

Regards,
Inam

Lynn

Quote from: inu on 09 Jan 2017 08:27:25 AM
Should i raise the PMR... What kind of tool IBM has developed, its a blunder bug.

Javascript, apart from the prompt API, is not supported in the product. This is noted in various places throughout the user guide as well as numerous posts on this forum, including some responses made directly to you. There are many who do not advocate the use of Javascript because it is prone to break and can be difficult to maintain.

This is not a problem with the tool that IBM has developed. Your criticism is based on flawed understanding and is, therefore, misdirected.

dougp

inu,
The "error" you posted 4 hours ago is not an error.  It is a warning.  It should not cause your code to fail.

If this is working in IE and not in a real browser, it's probably a problem with a reference to something in IE's document object model that's not in the standard document object model.  Open the report in Chrome, find your code (not IBM's code), put a break point in your code, refresh the page, and step through your code to where it fails.

hespora

Quote from: dougp on 09 Jan 2017 12:23:41 PM
If this is working in IE and not in a real browser,
Applauded for that quote alone. :D

BigChris


inu

Quote from: dougp on 09 Jan 2017 12:23:41 PM
inu,
The "error" you posted 4 hours ago is not an error.  It is a warning.  It should not cause your code to fail.

If this is working in IE and not in a real browser, it's probably a problem with a reference to something in IE's document object model that's not in the standard document object model.  Open the report in Chrome, find your code (not IBM's code), put a break point in your code, refresh the page, and step through your code to where it fails.

Hi dougp sir,
I used debugger in my js code, and when we click on reset button(js function), it stops that statement, which i took the snap shot , and posted here, i dont find any warning and error in my code, i showed to js specialist, he only told the same thing.
I posted the code as well , please see the same, and correct that , if anything wrong.
Please suggest.


Regards,
Inam

Invisi

Consider if Cognos offers a solution to your requested functionality that can do without Javascript.
Few can be done on Cognos | RTFM for those who ask basic questions...

dougp

Aside from the likelihood of IE causing problems, there's one core concept you're missing.

var oCR = cognos.Report.getReport("_THIS_");

That's not supported.  Yes, I know that there are blogs that show you how to use that to hack Cognos, but I think even they say it may not be supported in a different version of the software.  You also need to consider what Cognos needs to do to accommodate the functionality available in different browsers.  Maybe getControlByName is the problem because Cognos changes the name of the element from what you enter to something more reliable for Cognos.  (Actually, I think those same blogs state that.)

I've looked through your code.  Everything you are trying to do can be accomplished using the Prompt API, which is supported.  You can read about it in the Report Studio User Guide.

inu

Quote from: dougp on 11 Jan 2017 10:35:19 AM
Aside from the likelihood of IE causing problems, there's one core concept you're missing.

var oCR = cognos.Report.getReport("_THIS_");

That's not supported.  Yes, I know that there are blogs that show you how to use that to hack Cognos, but I think even they say it may not be supported in a different version of the software.  You also need to consider what Cognos needs to do to accommodate the functionality available in different browsers.  Maybe getControlByName is the problem because Cognos changes the name of the element from what you enter to something more reliable for Cognos.  (Actually, I think those same blogs state that.)

I've looked through your code.  Everything you are trying to do can be accomplished using the Prompt API, which is supported.  You can read about it in the Report Studio User Guide.

My requirement is to reset the values as defualt, that's why i used js code.
I used reprompt button as well, not working properly.
Please suggest.

Regards,
Inam






MFGF

Quote from: inu on 12 Jan 2017 02:14:18 AM
My requirement is to reset the values as defualt, that's why i used js code.
I used reprompt button as well, not working properly.
Please suggest.

Regards,
Inam

Firstly, I don't do javaScript. You probably know more javaScript than I ever will :)

Did you look at the section in the Report Studio User Guide on the Prompt API as dougp suggested? It's Appendix H if you haven't found it already. There is also a set of samples you can look at - these are mentioned on page 547. The guide is here: http://public.dhe.ibm.com/software/data/cognos/documentation/docs/en/10.2.2/ug_cr_rptstd.pdf
All this should tell you how to write javaScript code that is supported and should work. Doug also pointed out the pieces of your current code that are apparently unsupported. Your challenge is to replace the unsupported code with something that is supported and works.

Cheers!

MF.
Meep!

inu

Quote from: MFGF on 12 Jan 2017 03:51:59 AM
Firstly, I don't do javaScript. You probably know more javaScript than I ever will :)

Did you look at the section in the Report Studio User Guide on the Prompt API as dougp suggested? It's Appendix H if you haven't found it already. There is also a set of samples you can look at - these are mentioned on page 547. The guide is here: http://public.dhe.ibm.com/software/data/cognos/documentation/docs/en/10.2.2/ug_cr_rptstd.pdf
All this should tell you how to write javaScript code that is supported and should work. Doug also pointed out the pieces of your current code that are apparently unsupported. Your challenge is to replace the unsupported code with something that is supported and works.

Cheers!

MF.


Thanks MF. I will do that.

CognosPaul

var oCR = cognos.Report.getReport("_THIS_");  

That is Prompt API code. It's a direct copy from the Prompt API documentation. Ideally that should be inside it's own enclosure, but alone that's not the issue.

My guess the issue is coming from the button. Cognos doesn't like buttons. Use an input instead.

<input type="button" onclick="clearRefresh();" value="Reset"/>

inu

Quote from: CognosPaul on 12 Jan 2017 03:05:32 PM
var oCR = cognos.Report.getReport("_THIS_");  

That is Prompt API code. It's a direct copy from the Prompt API documentation. Ideally that should be inside it's own enclosure, but alone that's not the issue.

My guess the issue is coming from the button. Cognos doesn't like buttons. Use an input instead.

<input type="button" onclick="clearRefresh();" value="Reset"/>

Thanx CognosPaul, it worked, i will go through the doc which has been shared here before reaching out to you next time.
I put you people always in giving efforts and time. I am really  sorry for that.

Thanx.