Cognos Analytics

 View Only
  • 1.  how to make a date prompt empty

    Posted Thu March 10, 2022 03:08 PM

    Hello, after following the documentation number 298215 (How to make a date prompt empty by default in Cognos Analytics) i'm facing some problems. I followed each step but my date prompt is still not appearing empty, it's populated with the default current date. im using the v11.1.7 of cognos. Thanks for your help. Attached is my report in xml format.

    <report xmlns="http://developer.cognos.com/schemas/report/15.5/" expressionLocale="en" useStyleVersion="11.5"><!--RSU-SPC-0093 The report specification was upgraded from "http://developer.cognos.com/schemas/report/13.1/" to "http://developer.cognos.com/schemas/report/15.3/" at 2021-11-30. 15:9:51--> <drillBehavior/> <layouts> <layout> <reportPages> <page name="Page1"><style><defaultStyles><defaultStyle refStyle="pg"/></defaultStyles></style> <pageBody><style><defaultStyles><defaultStyle refStyle="pb"/></defaultStyles></style> <contents> <table><style><defaultStyles><defaultStyle refStyle="tb"/></defaultStyles><CSS value="width:100%;height:100%;border-spacing:0"/></style><tableRows><tableRow><tableCells><tableCell><contents><table><style><defaultStyles><defaultStyle refStyle="tb"/></defaultStyles><CSS value="width:100%;height:100%;border-spacing:0"/></style><tableRows><tableRow><tableCells><tableCell><contents><table><style><defaultStyles><defaultStyle refStyle="tb"/></defaultStyles><CSS value="border-collapse:collapse"/></style><tableRows><tableRow><tableCells><tableCell><contents><selectDate name="DatePrompt" parameter="" required="false" selectDateUI="editBox"/><HTMLItem> <dataSource> <staticValue>&lt;script language=&quot;javascript&quot;&gt; var formWR = getFormWarpRequest(); var dateTxtPrompt = formWR.txtDateDatePrompt dateTxtPrompt.value=&apos; &apos;; &lt;/script&gt;</staticValue></dataSource> </HTMLItem></contents><style><CSS value="text-align:center;vertical-align:top"/></style></tableCell></tableCells></tableRow><tableRow><tableCells><tableCell><contents><textItem><dataSource><staticValue/></dataSource></textItem></contents><style><CSS value="text-align:center;vertical-align:top"/></style></tableCell></tableCells></tableRow></tableRows></table></contents><style><CSS value="height:60px;text-align:center"/><defaultStyles><defaultStyle refStyle="ContentDataContainerTitleTableCell"/><defaultStyle refStyle="GuidedLayoutBottomPadding"/></defaultStyles></style></tableCell></tableCells></tableRow></tableRows></table></contents><style><CSS value="width:50%;height:100%"/><defaultStyles><defaultStyle refStyle="ContentDataContainerLeftColumnTableCell"/><defaultStyle refStyle="GuidedLayoutRightPadding"/></defaultStyles></style></tableCell></tableCells></tableRow></tableRows></table></contents> </pageBody> <pageFooter> <contents> </contents> <style> <CSS value="padding:10px"/> <defaultStyles><defaultStyle refStyle="FooterPageFooter"/></defaultStyles></style> </pageFooter> <pageHeader><contents/><style><defaultStyles><defaultStyle refStyle="ph"/></defaultStyles></style></pageHeader><XMLAttributes><XMLAttribute output="no" name="RS_legacyDrillDown" value="0"/></XMLAttributes></page> </reportPages> </layout> </layouts> <XMLAttributes><XMLAttribute output="no" name="RS_CreateExtendedDataItems" value="true"/><XMLAttribute output="no" name="listSeparator" value=","/><XMLAttribute output="no" name="decimalSeparator" value="."/></XMLAttributes><classStyles><classStyle name="GuidedLayoutLeftPadding"><CSS value="padding-left:5px;border-top-width:1px;border-bottom-width:1px;border-left-width:1px;border-right-width:1px"/></classStyle><classStyle name="GuidedLayoutTopPadding"><CSS value="padding-top:5px;border-top-width:1px;border-bottom-width:1px;border-left-width:1px;border-right-width:1px"/></classStyle><classStyle name="GuidedLayoutRightPadding"><CSS value="padding-right:5px;border-top-width:1px;border-bottom-width:1px;border-left-width:1px;border-right-width:1px"/></classStyle><classStyle name="GuidedLayoutBottomPadding"><CSS value="padding-bottom:5px;border-top-width:1px;border-bottom-width:1px;border-left-width:1px;border-right-width:1px"/></classStyle><classStyle name="GuidedLayoutMargin"><CSS value="margin-bottom:10px"/></classStyle></classStyles><reportName>New report</reportName></report>




    #CognosAnalytics
    #CognosAnalyticswithWatson
    #Support
    #SupportMigration


  • 2.  RE: how to make a date prompt empty

    Posted Sun March 27, 2022 11:40 AM

    The issue with your solution is that the <script>-tag get's filtered out by Cognos when running the report. You can workaround that by using onload or onerror event on an image.

    1. Create a class "MyDatePrompt" ... this will serve to identify your prompt
    2. Add that class to the surrounded the prompt
    3. In your HTML Item add an img with onerror or onload event and execute your Javascript there ... document.querySelector('.MyDatePrompt input').value=''

    <report xmlns="http://developer.cognos.com/schemas/report/16.0/" expressionLocale="en" useStyleVersion="11.5"><!--RSU-SPC-0093 The report specification was upgraded from "http://developer.cognos.com/schemas/report/15.5/" to "http://developer.cognos.com/schemas/report/16.0/" at 2022-3-27. 13:12:6--><!--RSU-SPC-0093 The report specification was upgraded from "http://developer.cognos.com/schemas/report/13.1/" to "http://developer.cognos.com/schemas/report/15.3/" at 2021-11-30. 15:9:51--> <drillBehavior/> <layouts> <layout> <reportPages> <page name="Page1"><style><defaultStyles><defaultStyle refStyle="pg"/></defaultStyles></style> <pageBody><style><defaultStyles><defaultStyle refStyle="pb"/></defaultStyles></style> <contents> <table><style><defaultStyles><defaultStyle refStyle="tb"/></defaultStyles><CSS value="width:100%;height:100%;border-spacing:0"/></style><tableRows><tableRow><tableCells><tableCell><contents><table><style><defaultStyles><defaultStyle refStyle="tb"/></defaultStyles><CSS value="width:100%;height:100%;border-spacing:0"/></style><tableRows><tableRow><tableCells><tableCell><contents><table><style><defaultStyles><defaultStyle refStyle="tb"/></defaultStyles><CSS value="border-collapse:collapse"/></style><tableRows><tableRow><tableCells><tableCell><contents><selectDate name="MyDatePrompt" parameter="" required="false" selectDateUI="editBox"/><HTMLItem> <dataSource> <staticValue>&lt;script language=&quot;javascript&quot;&gt; var formWR=getFormWarpRequest(); var dateTxtPrompt=formWR.txtDateDatePrompt; dateTxtPrompt.value=&apos; &apos;; alert(&apos;foo&apos;) &lt;/script&gt; &lt;img src=&quot;https://localhost/ibmcognos/bi/images/ca-content/Howtovideo.svg&quot; style=&quot;display:none&quot; onerror=&quot;document.querySelector(&apos;.MyDatePrompt input&apos;).value=&apos;&apos; ;alert(&apos;foo&apos;) &quot;&gt; &lt;/img&gt;</staticValue></dataSource> </HTMLItem></contents><style><CSS value="text-align:center;vertical-align:top"/><defaultStyles><defaultStyle refStyle="MyDatePrompt"/></defaultStyles></style></tableCell></tableCells></tableRow><tableRow><tableCells><tableCell><contents><textItem><dataSource><staticValue/></dataSource></textItem></contents><style><CSS value="text-align:center;vertical-align:top"/></style></tableCell></tableCells></tableRow></tableRows></table></contents><style><CSS value="height:60px;text-align:center"/><defaultStyles><defaultStyle refStyle="ContentDataContainerTitleTableCell"/><defaultStyle refStyle="GuidedLayoutBottomPadding"/></defaultStyles></style></tableCell></tableCells></tableRow></tableRows></table></contents><style><CSS value="width:50%;height:100%"/><defaultStyles><defaultStyle refStyle="ContentDataContainerLeftColumnTableCell"/><defaultStyle refStyle="GuidedLayoutRightPadding"/></defaultStyles></style></tableCell></tableCells></tableRow></tableRows></table></contents> </pageBody> <pageFooter> <contents> </contents> <style> <CSS value="padding:10px"/> <defaultStyles><defaultStyle refStyle="FooterPageFooter"/></defaultStyles></style> </pageFooter> <pageHeader><contents/><style><defaultStyles><defaultStyle refStyle="ph"/></defaultStyles></style></pageHeader><XMLAttributes><XMLAttribute output="no" name="RS_legacyDrillDown" value="0"/></XMLAttributes></page> </reportPages> </layout> </layouts> <XMLAttributes><XMLAttribute name="RS_CreateExtendedDataItems" output="no" value="true"/><XMLAttribute name="listSeparator" output="no" value=","/><XMLAttribute name="decimalSeparator" output="no" value="."/></XMLAttributes><classStyles><classStyle name="GuidedLayoutLeftPadding"><CSS value="padding-left:5px;border-top-width:1px;border-bottom-width:1px;border-left-width:1px;border-right-width:1px"/></classStyle><classStyle name="GuidedLayoutTopPadding"><CSS value="padding-top:5px;border-top-width:1px;border-bottom-width:1px;border-left-width:1px;border-right-width:1px"/></classStyle><classStyle name="GuidedLayoutRightPadding"><CSS value="padding-right:5px;border-top-width:1px;border-bottom-width:1px;border-left-width:1px;border-right-width:1px"/></classStyle><classStyle name="GuidedLayoutBottomPadding"><CSS value="padding-bottom:5px;border-top-width:1px;border-bottom-width:1px;border-left-width:1px;border-right-width:1px"/></classStyle><classStyle name="GuidedLayoutMargin"><CSS value="margin-bottom:10px"/></classStyle></classStyles><reportName>New report</reportName></report>

    Hope that helps ... let me know any concerns.

    Ralf






    #CognosAnalytics
    #CognosAnalyticswithWatson
    #Support
    #SupportMigration


  • 3.  RE: how to make a date prompt empty

    Posted Mon March 28, 2022 01:58 PM

    Hello Ralf, Thanks a lot for your answer, isn't there another way to clear the default date prompt without using a pop up? 

    Thanks for your help.






    #CognosAnalytics
    #CognosAnalyticswithWatson
    #Support
    #SupportMigration


  • 4.  RE: how to make a date prompt empty

    Posted Mon March 28, 2022 05:48 PM

    The popUp is just for debugging :-D to show you that the code is executed.

    Just remove: alert("foo") - that will remove the popUp.






    #CognosAnalytics
    #CognosAnalyticswithWatson
    #Support
    #SupportMigration


  • 5.  RE: how to make a date prompt empty

    Posted Mon March 28, 2022 05:51 PM

    Regarding the not found image "popup".

    Replace it with an image found n your server and a valid address. And change "onerror" to "onload".

    Or Replace domain "localhost" with "this.is.not.existing".

    if you replace the "localhost" with our server name and "ibmcognos" with the path of your installation ... this should actually load an image without popup ... https://localhost/ibmcognos/bi/images/ca-content/Howtovideo.svg

    Try the link a browser until you see an image and replace "onerror" with "onload"

    Let me know any concerns






    #CognosAnalytics
    #CognosAnalyticswithWatson
    #Support
    #SupportMigration


  • 6.  RE: how to make a date prompt empty

    Posted Tue March 29, 2022 01:33 PM

    Hello Ralph,

    Thanks a lot for your help, your solution works well when my date prompt range option is disable, when I enable it the fields fill automatically, is there a solution?









    #CognosAnalytics
    #CognosAnalyticswithWatson
    #Support
    #SupportMigration