Cognos Analytics

Cognos Analytics

Connect, learn, and share with thousands of IBM Cognos Analytics users! 

 View Only
  • 1.  Clear selections and results from Select and Search prompt

    Posted Tue January 07, 2020 08:59 AM

    Hi,

    I would appreciate any help on the following issue:

    I 'm trying to fully clear (selection and results) a SnS (Select and Search) prompt by weaking the script CustomFinishCancelClear.js which is a sample script of Cognos (ClearPromptSelections folder) with no success.
    What I have managed up to now are explained on the following steps:
    I have two SnS prompts and I perform a search on both and select something on both (Prompt_Page_Initial.PNG)
    I click on Clear button and get the expected result (Prompt_Page_AfterClear.PNG)
    The problem appears in case that I'm trying to perform another search on the first SnS where the previous results appear on the second SnS without actually search anything on this (Prompt_Page_Search_AfterClear.PNG).


    I attach the script as well as the report specification that I use (CustomFinishCancelClear_case.js,report.txt )

    I'm not able to attach the files for some reason but I can send it to anyone that might need them.

    Kind Regards,

    ------------------------------
    Pantelis Stavroulidakis
    ------------------------------

    #CognosAnalyticswithWatson


  • 2.  RE: Clear selections and results from Select and Search prompt

    Posted Tue January 07, 2020 10:07 AM
    @Pantelis Stavroulidakis I don't see any attached files, but you may just need to issue a reprompt(); after you clear the values. If your script files do get attached I will have a look.​​​

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



  • 3.  RE: Clear selections and results from Select and Search prompt

    Posted Tue January 07, 2020 11:18 AM

    Dear Denny,

    I tried to attach the files using many browsers but for some reason Attach button didn't work. Do you have any suggestion?
    If you have any other alternative to send you these files let me know.

    Thanks in advance,



    ------------------------------
    Pantelis Stavroulidakis
    ------------------------------



  • 4.  RE: Clear selections and results from Select and Search prompt

    Posted Tue January 07, 2020 11:23 AM
    You can send them to my email: denny.narezny@ca.ibm.com

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



  • 5.  RE: Clear selections and results from Select and Search prompt

    Posted Fri February 05, 2021 06:27 PM
    @Pantelis Stavroulidakis - did you solve your problem? I am exactly at the stage where you are at. If its solved please let me know what was done to fix it?​

    ------------------------------
    Zameer Sayed
    ------------------------------



  • 6.  RE: Clear selections and results from Select and Search prompt

    Posted Mon February 08, 2021 02:22 AM
      |   view attached

    Dear Zammer,

     

    It has been a long time since I tried to solve this issue. What I remember is that I tried to clean my Search and Select prompt as well other prompts by clearing manually its HTML items (check lines 70-102). I'm attaching the script and copied here as well providing the steps to include it in your report.

     

    Hope this helps.

    Custom Control Clear Selections
    1. Enter the custom control and set the value in the Module path:
    /ibmcognos/samples/javascript/ClearPromptSelections_BOG/CustomFinishCancelClear.js
    2. If there are date prompts we define a data set in the custom control which is the same as the custom control that sets the default dates.


    define([
    ]
    ,function () {
    "use strict";

    function validatePromptValue() {
    };


    validatePromptValue.prototype.draw = function (oControlHost) {

    /* for date prompts*/


    var el = oControlHost.container;
    el.innerHTML =
    '<style>' +
    '.myButton { height:36px; width:120px; cursor:pointer; margin-left:10px; color:#FFFFFF; font-size:14px; font-weight:bold; padding:6px 12px 6px 12px; background-color:#BC9E6E; border:1px solid #BC9E6E; }' +
    '.myButton:hover { background-color:#BC9E6E; color:white; border:1px solid #BC9E6E; }' +
    '</style>' +
    '<button class="myButton btnClear" type="button">Καθαρισμός</button>';
    el.querySelector(".btnClear").onclick = this.f_clearButtonClick.bind(this, oControlHost);
    };


    validatePromptValue.prototype.finishButtonClick = function (oControlHost) {

    oControlHost.finish();

    };


    validatePromptValue.prototype.f_clearButtonClick = function (oControlHost) {
    var aControls = oControlHost.page.getAllPromptControls();

    /* Set default values on date prompts */
    var o = oControlHost.configuration
    , secondaryRun
    , dynStartDate
    , dynEndDate
    , datastores
    ;
    //optional dynDate from configuration
    if(!secondaryRun&&o&&o["dynStartDate"]&&moment(eval(o["dynStartDate"])).isValid()) {
    dynStartDate=moment(eval(o["dynStartDate"])).format('YYYY-MM-DD');
    };

    //optional dynDate from configuration
    if(!secondaryRun&&o&&o["dynEndDate"]&&moment(eval(o["dynEndDate"])).isValid()) {
    dynEndDate=moment(eval(o["dynEndDate"])).format('YYYY-MM-DD');
    };
    //check for datasets
    if(oControlHost.control.dataStores) datastores = oControlHost.control.dataStores;

    if(datastores&&datastores.length>0){
    //if datastores have been found, let's start looking for minDate. First we loop through the datastores
    for(var i=0;i<datastores.length;++i){
    //then we loop through the columns
    for(var j=0;j<datastores[i].columnNames.length;++j){
    //test for dynDate
    if(datastores[i].columnNames[j]=='dynStartDate') dynStartDate = datastores[i].columnValues[j][0].substring(0,10);
    if(datastores[i].columnNames[j]=='dynEndDate') dynEndDate = datastores[i].columnValues[j][0].substring(0,10);
    }
    }

    };
    /* End of Set default values on date prompts */


    for (var i = aControls.length - 1; i >= 0 && aControls[i].name != 'SearchText'; i--) {

    var oControl = aControls[i]
    var prmptElm
    var srchTxt
    var resBox
    if (oControl.name.match(/^pDateFrom.*$/)) {
    oControl.setValues([{'use':dynStartDate}]);
    } else if ((oControl.name.match(/^pDateTo.*$/))) {
    oControl.setValues([{'use':dynEndDate}]);
    }else if ((oControl.name.match(/^mySnS.*$/))) {
    prmptElm = oControl.element;
    oControl.clearValues();
    srchTxt = prmptElm.getElementsByClassName('clsSearchText')[0];
    srchTxt.value= '';
    resBox =prmptElm.getElementsByClassName('clsAdorment')[0];
    if (resBox.childElementCount == 1) // check for single-select or multiple select
    {
    for (var k = 0; k < resBox.childElementCount ; k++)
    {resBox.removeChild(resBox.childNodes[k]);
    }
    }
    else {
    for (var k = 0; k < resBox.childElementCount ; k++)
    {resBox.removeChild(resBox.childNodes[k]);
    resBox.removeChild(resBox.childNodes[k++]);
    }
    }
    }
    else {
    oControl.clearValues();
    }
    }


    sessionStorage.setItem(this.ctrlFrom+'ClearPrompts',1);
    // call FromToDateValidation();
    // reload
    for (var i = aControls.length - 1; i >= 0 ; i--) {
    var oControl = aControls[i]
    if (aControls[i].name.match(/^Searchtext.*$/))
    {
    //oControl.clearValues();
    oControl.setValues([{'use': '' }]);
    }
    }

    oControlHost.reprompt();

    };

    return validatePromptValue;
    });




    ------------------------------
    Pantelis Stavroulidakis
    ------------------------------

    Attachment(s)