Cognos Analytics

 View Only
Expand all | Collapse all

Cognos 11.0.11 - Set a Start Date Value for a prompt

  • 1.  Cognos 11.0.11 - Set a Start Date Value for a prompt

    Posted Wed May 15, 2019 08:49 AM
    ​I am using a Date prompts for selecting a 'Date Open between ?begin date? and ?End Date?
    I'd like to set the 'Begin Date? to be the first day of the current year, however, I am not able to get the 'html' to work in setting this default.

    I've tried this code along with setting the 'Name' property for this prompt to 'StartDate'

    <script language="javascript"> //Months are 0 to 11 var dDate = new Date(); dDate.setMonth(0); dDate.setDate(1); pickerControlStartDate.setValue(getFormatDate(dDate, 0 , 'YMD')); </script>

    Any ideas what I may not be doing right?

    Thank you!!
     


    ------------------------------
    Jenifer Broughton
    ------------------------------

    #CognosAnalyticswithWatson


  • 2.  RE: Cognos 11.0.11 - Set a Start Date Value for a prompt

    Posted Tue May 28, 2019 07:52 AM
      |   view attached
    @Jenifer Broughton I was able to get this to work. I've attached a copy of my report spec. Also if you are using Javascript and not custom controls, you need to make sure you set Run with Full Interactivity to No or the Javascript will not execute. ​

    ------------------------------
    DENNY NAREZNY
    ------------------------------

    Attachment(s)

    txt
    IBM JS Start Date.txt   3 KB 1 version


  • 3.  RE: Cognos 11.0.11 - Set a Start Date Value for a prompt

    Posted Tue May 28, 2019 03:45 PM
    ​Hi Denny,
    we are using IBM Cognos Analytics 11.1 R1. I have a SQL based report and there is a value prompt in the prompt page. I want when  prompt page execute the value prompt in the prompt page get the first value from its query . So that when I submit the prompt page I can pass that first value from the value prompt to my SQL statement in my where clause so that I can filter my sql based query. Now we use to manage all these  in cognos 10 by using HTML item in front of the value prompt and then use the code
    </script>
    <body onLoad=init()>
    <script type="text/javascript">
    function init()
    {
    var fW = (typeof getFormWarpRequest == "function" ? getFormWarpRequest() : document.forms["formWarpRequest"]);
    if (fW)
    fW._oLstChoicesMyDistrict.options[2].selected = true;
    }
    init();
    </script>

    Now in cognos 11 I want to keep my report in interactive mode and does not want to use this HTML in the prompt page but I want to learn how can I implement this in cognos 11.1 R1. using Custom control. Thanks again for your help.
    Regards,
    Pradeep Sahay

    ------------------------------
    pradeep sahay
    ------------------------------



  • 4.  RE: Cognos 11.0.11 - Set a Start Date Value for a prompt

    Posted Wed May 29, 2019 12:25 PM

    @Pradeep Sahay

    Attached is an example page module control and report spec that pre-selects the first value in a prompt control.​

    For details on how to use the new controls, I would suggest reviewing the below links:


    https://www.ibm.com/communities/analytics/cognos-analytics-blog/ibm-cognos-analytics-11-javascript-what-is-the-difference-between-a-custom-control-and-a-page-module/


    https://www.ibm.com/support/knowledgecenter/en/SSEP7J_11.1.0/com.ibm.swg.ba.cognos.ug_cr_rptstd.doc/t_rpting_add_javascrpt.html
     ​



    ------------------------------
    DENNY NAREZNY
    ------------------------------

    Attachment(s)

    js
    setPromptValues.js   416 B 1 version


  • 5.  RE: Cognos 11.0.11 - Set a Start Date Value for a prompt

    Posted Thu May 30, 2019 04:25 PM
    ​Hi Denny,
    Thanks for the reply and all your help I really appreciate it. Thanks for sending me the link for all the java script sample reports and I did  download them in our cognos environment and now can understand a bit how its all working.
    I tried copying your xml which you gave me but I get a error message saying ( The latest package information could not be loaded. The package this report is referencing may no longer exist. Package metadata is required for proper operation of the user interface. Certain elements of the report definition may not be viewable or editable.)
    So I tried to create a sample report for me. I created a data module from SampleFile_GOSales.xls and then created a sample report from using the data module as my source.
     I created a folder called setPromptValues in my cognos server (C:\Program Files\ ibm\cognos\analytics\webcontent\samples\javascript) and copied the java script you gave me (setPromptValues.JS) but this is not working. It is giving me error when I run the report .Please find the report XML and also the error which I am getting attached . Can you please help me this. Thanks again for all your help. Thanks.

    Regards
    Pradeep Sahay

    ------------------------------
    pradeep sahay
    ------------------------------

    Attachment(s)

    docx
    Test Doc.docx   44 KB 1 version
    txt
    Test XML.txt   7 KB 1 version


  • 6.  RE: Cognos 11.0.11 - Set a Start Date Value for a prompt

    Posted Thu May 30, 2019 09:26 PM

    @Pradeep Sahay I've attached a modified version of your report spec and an updated JS file. Please test using the updated files. For your report spec you need specify a name for the Name property of the prompt control. The Name property is how the Prompt Control is referenced by the Page Control (JS)



    ------------------------------
    DENNY NAREZNY
    ------------------------------

    Attachment(s)

    txt
    IBMSetPromptValueRS.txt   7 KB 1 version
    js
    setPromptValues.js   413 B 1 version


  • 7.  RE: Cognos 11.0.11 - Set a Start Date Value for a prompt

    Posted Fri May 31, 2019 12:05 PM
      |   view attached
    Hi Denny,
    Thanks again for your reply. I really thankful to you for all your help. Yes I missed the name of the value prompt and that's why I was getting the error which I send you yesterday.
    So today I tried again with the new java script and the new report xml you send me. The only change I see in the java script is ​oControl.addValues( [oValues[2]] ); the value was set  to 0 last time.
    The Only change I saw in the report is that the name of the prompt was set to Product line. which was missing last time.
     Please see my new report xml which should be totally identical with what you have send me. Now I am not getting the error which I send you yesterday. Its just now its not selecting the first value. Its is still forcing me to select the first value of the value prompt. it just does not execute the java script when I run the prompt page. Please let me know if I am still missing anything here.
    I was also checking on the sample java report which is called Page Module report. but if you see the prompt there is a default value defined in it and if you take that default value out then it does not work either.
    Please find my new report xml attached. Thanks again for all your help. Its just that if this work I can convert lots of my sql based reports to interactive mode. Thanks.

    Regards,
    Pradeep Sahay  


    ------------------------------
    pradeep sahay
    ------------------------------

    Attachment(s)

    txt
    Test XML.txt   7 KB 1 version


  • 8.  RE: Cognos 11.0.11 - Set a Start Date Value for a prompt

    Posted Fri May 31, 2019 01:36 PM

    Hey Pradeep,

    Your sample works for me. Could you also send across your js file so I can have a look?



    ------------------------------
    DENNY NAREZNY
    ------------------------------



  • 9.  RE: Cognos 11.0.11 - Set a Start Date Value for a prompt

    Posted Fri May 31, 2019 02:05 PM
      |   view attached
    Hi Denny,
    Thanks again yes of course. I have created a folder in web content by name ​setPromptValues. you can see the path
    (C:\Program Files\ibm\cognos\analytics\webcontent\samples\javascript\setPromptValues) . Iam attaching the JS file. Thanks again.
    Regards,
    Pradeep Sahay

    ------------------------------
    pradeep sahay
    ------------------------------

    Attachment(s)

    js
    setPromptValues.js   413 B 1 version


  • 10.  RE: Cognos 11.0.11 - Set a Start Date Value for a prompt

    Posted Fri May 31, 2019 02:36 PM
    Works for me without issue. Are you using a gateway in your environment or going directly against the dispatcher? If you are using a gateway you will need to update the module path in the report to include the web alias name. For example, if you are hitting https://ott.ibm.com/ibmcognos/bi you will need to update the module path to include ibmcognos

    /ibmcognos/samples/javascript/setPromptValues/setPromptValues3.js ​

    ------------------------------
    DENNY NAREZNY
    ------------------------------