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

 

javascript to select the first value as default value and refresh the prompt not

Started by xyz, 17 Dec 2014 10:40:17 AM

Previous topic - Next topic

xyz

Hi All,

I don't know where exactly to put my question though, as I was into my release in December before 15th, I have used java script and ran into issues when I upgraded my IE browser from IE9 to IE11, java script basically does select the first value of the value prompt as a default and then refresh the page. I am using Congos 10.2.1 version. Please find my java script below. Can some one please help me to debug the issue.

Basically I am using this java script in report studio and finally pulling this reports into workspace. Based on a selection of a value in value prompt which is in global area, I am rendering one more value prompt in the workspace, the value prompt in the workspace uses the javascript which is given below and tries to refresh the workspace. Based on the selection of different values of value prompt in global area different value prompts render in workspace and based on the first selection of value prompt in workspace a list report has to filter the data. As I have two tabs in workspace, my value prompt with the javascript resides in second tab. Problem here I am facing is, there is a default value in the value prompt in global area, when I select a different value in value prompt of global area then changes reflect in the first tab, when I move to the second tab then value prompt with java script renders fine, whereas the list widget which has to be filtered based on the value of value prompt in the workspace doesn't work as expected. I have used the java script in global area and for the value prompt in workspace and the list widget and then made them invisible.

Can some one let me know, is there issue in the java script or prompt API's are wrong or my approach is wrong.

I am thinking of reloading the list widget on the initial load would solve my problem, but require suggestion though?

Your help is much appreciated :)

<script>
// Attach functions to an arbitrarily named object to mimic a namespace to ensure the name uniqueness
var zxcv = {};
var oValues ;
// Get the required prompt.
var oCR = cognos.Report.getReport("_THIS_");
var oP = oCR.prompt.getControlByName("Excptn");
// Get the values and isolate the first value.
var allValues = oP.getValues(true);
var firstValue = allValues[0];

//Get the selected value
var selectedValues =oP.getValues();
var value = selectedValues
  • ;
    //alert(selectedValues .length);

    if(value == undefined) {
        //Set the first element as selected initialy
        oValues = [firstValue ];
    //alert(oValues);

        oP.setValues(oValues);
    setTimeout("promptButtonFinish();",300);
    } else {
        //Set the selected value
        oValues = [value];
    //alert(selectedValues .length);
    //alert(oValues.length);
    // oP.setValues(oValues);
    oP.setValues(selectedValues );

    }
    </script>


    Thanks & Regards,
    XYZ

xyz

Hi All,

Can someone please provide me a java script to refresh the report page on initial loading for Cognos 10.2.1.


Thanks & Regards,
XYZ

qvixote

Are you using IE11 in compatibility mode? Because it's the recomended way to work with Report Studio in IE11.

xyz

Thanks for reply qviquote, yes I am using compatibility mode only.

xyz


xyz

Hi All,

Can some one provide me java script for Cognos 10.2.1 to refresh the page once it is loaded. I am unable to find the prompt page API.
I have the below java script, it is not working and giving getSource() is not a valid function.

<script>

var paulScripts = {}
, oCR = cognos.Report.getReport("_THIS_");


function onLoad()

{
if(!paulScripts.getSource() ) return true;
  setTimeout("promptButtonFinish();",300);
  return true;
}

onLoad();


</script>

Can some one help me on the same.

Thanks & Regards,
XYZ

BigChris

I know _square_root(nothing) about javascript I'm afraid. Looking at the code, it looks like there's a variable called oCR...does that need to go inside the brackets of the functions? Something like:

if(!paulScripts.getSource( oCR ) ) return true

Please bear in mind that I have no idea what I'm talking about..it's the sort of thing that I'd try though.


xyz

Hi Chris,

Thanks for the reply, but still it is not working as expected.



Thanks & Regards,
XYZ

MFGF

Quote from: xyz on 18 Dec 2014 08:53:23 AM
...it is not working as expected.

Two points here. Firstly, "it is not working as expected" doesn't tell anyone what the problem is. I know less about Javascript than I know about the migration habits of monarch butterflies (and I know nothing whatsoever about Lepidoptera), so I can't add anything of any value to this thread in terms of a solution for you. Notwithstanding, even in my state of complete Javascript ignorance, I can see that you haven't provided anything like enough information for a Javascript-literate person to be able to assist you. "It is not working" is, quite probably, the most unhelpful, vague, meaningless thing you could post. What does it mean? Do you get an error? If so, what is it? Do you get an unexpected result? If so, what result do you get? Do you get no result? Something else? How can you expect people to post up anything constructive and helpful when all they have to go on is "it is not working as expected"?

Secondly, you seem to be behaving in a rather impatient manner, asking again and again (within very short intervals of time) if someone can help you. Please don't. It appears very rude, and people don't respond at all well to forum members who appear to be pushy and demanding. If people read your post and can contribute anything meaningful, they will. If not, they won't. Pushing for an answer simply serves to annoy and deter potential posters. Please behave in a courteous and respectful manner towards other forum members and stop demanding answers when you don't get an immediate reply.

Thanks,

MF.
Meep!

Lynn

I got this personal message from xyz

QuoteHi Lynn,

Can you please give some suggestions and ideas on the above topic "java script to select the first value as default value and refresh the prompt not". Actually I am stuck, I was thinking to refresh the list report once it loaded.

Your help is much appreciated.

Thanks & Regards,
XYZ

I don't have any javascript expertise to offer.

xyz

My apologize MFGF,

It will be taken care, when I debugged the java script below to refresh the page after initial, I was getting getSource is not a valid function error.

<script>
var paulScripts = {}
, oCR = cognos.Report.getReport("_THIS_");
function onLoad()
{
if(!paulScripts.getSource() ) return true;   // getSource function is not a valid function error
  setTimeout("promptButtonFinish();",300);
  return true;
}
onLoad();
</script>

As well as the java script below which selects the first value by default for the value prompt and refresh the report page, I was getting the null value getting passed into oP variable, which say .getValues function is unidentified as null. I am unable to understand how the null is getting passed here, so in order to pass some value to oP variable, I want to refresh the report page using the above java script. That is not working.

<script>
var zxcv = {};
var oValues ;
var oCR = cognos.Report.getReport("_THIS_");
var oP = oCR.prompt.getControlByName("Type"); //oP value is getting null here, where first value prompt is the default value prompt
var allValues = oP.getValues(true);  //.getValues is unidentified as null
var firstValue = allValues[0];
var selectedValues =oP.getValues();
var value = selectedValues
  • ;

    if(value == undefined && value == "")
    {
        oValues = [firstValue ];
        oP.setValues(oValues);
    setTimeout("promptButtonFinish();",300);
    }
    else
    {
      oValues = [value];
      oP.setValues(selectedValues );
    }
    </script>

    Basically I was posting replies back to back, thinking I may get some help on it, as my product release is hold off due to this issue. Because, we have good experts, who could solve the issue within five to 10 minutes of their time like Paul/Nimrod Avisaar/Lynn  off course MFGF etc, other apologize, if I have missed any of your names.

    I will take care of it, I hope you understand :)

    Thanks & Regards,
    XYZ

MFGF

Quote from: Lynn on 18 Dec 2014 09:44:04 AM
I got this personal message from xyz

I don't have any javascript expertise to offer.

So as well as pushing people to reply in the public thread, you're sending personal messages to members pushing for answers too? That gets a "warn" from me for selfish, demanding behaviour, xyz.

Members will reply to threads if they have ideas and if they have the time to contribute. It is hugely unfair to put individuals "on the spot" by repeating questions to them in personal messages, as they feel compelled to reply. I understand that you may be under pressure to get an answer, but behaving in this way is not an acceptable consequence.

MF.
Meep!

xyz

Hi MFGF,

My apologies again, I agree that I should not have sent the personal message to any one bothering them it is against forum etiquettes, the fact is that I have sent the Personal message already before I post apologise message. It will be taken care. As it is some thing real and high importance issue to me and a show stopper I did it. It will be taken care.


Thanks & Regards,
Xyz