Cognos Analytics

 View Only
Expand all | Collapse all

Custom button to run report in other outputs

  • 1.  Custom button to run report in other outputs

    Posted Mon May 30, 2022 04:28 PM

    Hi, guys!

    Did anyone write a custom control that execute a report in another outputs like PDF or CSV?

    My need is: in prompt page, add a "Finish" button that executes a report in CSV, PDF, or Excel.

    Kind of "Finish CSV", "Finish "PDF", etc.

    I don't need the entire custom control, but the method that I should call to change report output format.

    For example, we have "oControlHost.next()" to submit the report or prompt page.

    Drill thru does not meet my need, because in prompt page level, prompts are not passed (if the report/prompts was not submitted yet).



    ------------------------------
    JEAM COELHO
    Cognos Solution Architect

    LinkedIn: https://www.linkedin.com/in/jeamcoelho/
    ------------------------------

    #CognosAnalyticswithWatson


  • 2.  RE: Custom button to run report in other outputs

    IBM Champion
    Posted Tue May 31, 2022 02:20 AM
    Hi 

    Take a look at cogbox, in the free version you have pdf and excel export

    Br
    René

    ------------------------------
    René Kent Nielsen
    Brand manager
    CogniTech A/S
    Herning
    ------------------------------



  • 3.  RE: Custom button to run report in other outputs

    Posted Tue May 31, 2022 09:52 AM

    Hi, René.

    Thanks for your help.

    Although Cogbox export does not met my needs.

    The custom control code is javacript obfuscated, but I could see that it is calling report itself by SOAP request, passing the format output parameters.

    It is not my case, because report is not generated yet, I'm at prompt page. If reports has already executed, drill thru would solve.



    ------------------------------
    JEAM COELHO
    Cognos Solution Architect

    LinkedIn: https://www.linkedin.com/in/jeamcoelho/
    ------------------------------



  • 4.  RE: Custom button to run report in other outputs

    Posted Wed June 01, 2022 02:14 AM
    Hello Jeam, 

    Can you move your prompts to the report page itself (in case all of them are optional or defaults can be set) and use the custom controls? Just a thought!!!

    Regards,
    Kiran

    ------------------------------
    Kiran Passumarthi
    www.linkedin.com/in/kiranpassumarthi
    ------------------------------



  • 5.  RE: Custom button to run report in other outputs

    IBM Champion
    Posted Wed June 01, 2022 05:44 PM
    Hey Jeam.

    You are absolutely correct. The version of export report doesn't meet your needs. That being said, it now does. If one of my scripts is missing an important feature like this, let me know, I'll get it in. 

    I've added a new parameter "Use Prompts". If set to true, it will collect all of the prompts on the page and generate the promptAnswers based on that. If you set "Use Prompts" to an array of prompt names, it will pull the parameters only from those. So you could have three prompts on the page. "Use Prompts":true would get them all. "Use Prompts":["Prompt 1","Prompt 3"] would only get two of them.

    {
        "Button Icon": "fa-solid fa-file-excel",
        "Button Text": "",
        "Button Class": "myCustomClass",
        "Button Custom CSS": {
            "border": "1px solid transparent",
            "padding": 0,
            "cursor": "pointer",
            "font-size": "20pt",
            "background": "transparent"
        },
        "Button Hover CSS": {
            "color": "#1D6F42!important"
        },
        "Export Format": "Excel",
        "Interactive Export": false,
        "Server": "",
        "Target Report": "",
        "File Name": [
            {
                "type": "reportName"
            },
            " - Exported by ",
            {
                "type": "username"
            },
            " - ",
            {
                "type": "date"
            }
        ],
        "Use Prompts": true
    }​​
    1. Button Icon - CogBox uses font-awesome icons. You can use any of the free icons listed here: https://fontawesome.com/search?q=file&s=solid
    2. Button Text - If you don't want to use an icon, just put some text in here. Icons take preference.
    3. Button Class - You can manually assign a class to the icon. Useful if you're using stylesheets.
    4. Button Custom CSS - if you're not using a style sheet, you can assign whatever CSS you want directly to the button. The style listed above is the default if the Button Custom CSS property is removed.
    5. Button Hover CSS - What do you want the button to look like if the user hovers over it. Again, the style in the example is the default
    6. Export Format - Can be excel, pdf, csv, or xml. Not case sensitive. 
    7. Interactive Mode - True/false. In this version I've had to change the logic so it's exactly replicating a user clicking on run->excel from the menu. This will preserve interactive mode changes like sorting and filtering, but it will ignore the file name and target report settings below.
    8. Server - <https://servername/ibmcognos/bi/v1/disp/rds/outputFormat/searchPath/" You can safely leave this blank, it will use the hostname from the browser session. I added it for some test cases I needed to do at a client.
    9. Target Report - Use the search path of the desired report, if null it will use the search path of the current report. If left blank you will not be able to click the button when run from report studio.
    10. File Name - Uses addText syntax
      addTextArray syntax:
      This is an array of items that will be converted into a string. It is possible to stack static strings
      with text inside a block or a text item, parameter value use/display, prompt use/display.

      1. "static text"
      2. {"type":"variable","name":"variable name"}
      3. {"type":"text","name":"text item name"}
      4. {"type":"block","name":"block name"}
      5. {"type":"prompt","name":"prompt name"} returns the selected display values from the prompt
      6. {"type":"promptDisplay","name":"prompt name"}
      7. {"type":"promptUse","name":"prompt name"}
      8. {"type":"parameter","name":"parameter name"} unlike the prompt, this is a parameter value from the report. this is more likely to reflect the current state of a report.
      9. {"type":"parameterDisplay","name":"parameter name"}
      10. {"type":"parameterUse","name":"parameter name"}
      11. {"type":"username"}
      12. {"type":"user display name"}
      13. {"type":"date"}
      14. {"type":"reportName"} important note! this only works when the report is run from the report page.
    11. Use Prompts - As mentioned above. true will return all of the prompts, array of prompt names to limit to a set.

    I'm probably going to do the next release later this month, so I've attached the latest exportReport here. Just replace the file in the js\controllers\Controls folder in the zip file. Also attached is a quick test report I made to confirm it's actually working.

    Contact me at cognospaul@gmail.com if you need any more help with it. 

    BTW: It is obfuscated for legal reasons (so I'm told, it's above my pay grade).



    ------------------------------
    Paul Mendelson
    ------------------------------

    Attachment(s)

    js
    exportReport.js   12 KB 1 version


  • 6.  RE: Custom button to run report in other outputs

    Posted Mon June 06, 2022 06:20 PM
    Hi, Paul!

    Thanks for your support! It's a pleasure to be helped by you.

    So, I guess I got your point!

    Using getAllPromptControls() and getValues(), I could get select values of a page and then build an URL (based on Cognos Mashup - rds) with theses values.

    I think that it will work fine.

    Best regards,


    ------------------------------
    JEAM COELHO
    Cognos Solution Architect

    LinkedIn: https://www.linkedin.com/in/jeamcoelho/
    ------------------------------



  • 7.  RE: Custom button to run report in other outputs

    IBM Champion
    Posted Tue June 07, 2022 03:26 AM
    That's pretty much exactly what I do in the script. If you need the display values, make sure to pass the use and display in the promptAnswers xml block.

    &xmlData=<promptAnswers><promptValues><name>Product Line</name><values><item><SimplePValue><inclusive>true</inclusive><useValue>12345</useValue><displayValue>ReplaceAmpersandsWith%26amp;</displayValue></SimplePValue></item></values></promptAnswers>​


    Also, if all of the prompts are optional, I recommend passing a dummy parameter value. Even if all of the prompts are optional, and you're passing prompt=false, you'll still get the stupid "required parameters not provided" error. 

    `p_dummy=false&prompt=false&async=off&xmlData=${params.xml}`

    Have you tried the script I provided above? It should do all of the things you're asking for now.



    ------------------------------
    Paul Mendelson
    ------------------------------



  • 8.  RE: Custom button to run report in other outputs

    Posted Tue June 07, 2022 07:39 AM
    Hi Paul,

    I'm thinking about this solution yet.

    To avoid Cognos being a direct source of other tools, rds location is blocked in my environment by Apache directive

    In meanwhile, thanks for your ideas.

    ------------------------------
    JEAM COELHO
    Cognos Solution Architect

    LinkedIn: https://www.linkedin.com/in/jeamcoelho/
    ------------------------------



  • 9.  RE: Custom button to run report in other outputs

    IBM Champion
    Posted Wed June 08, 2022 10:34 AM
    I think there might be a way to call the report with parameters through the monitor service. This would bypass RDS altogether, but it does involve using some undocumented internal APIs. I'll dig into it.

    ------------------------------
    Paul Mendelson
    ------------------------------



  • 10.  RE: Custom button to run report in other outputs

    IBM Champion
    Posted Tue May 31, 2022 10:01 AM
    Hi Jeam,

    There is nothing available with run() method associated with ControlHost:
    Scriptable reports

    Note: it seems strange that this documentation is up-to-date with only Cognos Analytics v11.1.0 (last update, nearly 2 years ago)!

    Best regards,

    ------------------------------
    Patrick Neveu
    Positive Thinking Company
    ------------------------------



  • 11.  RE: Custom button to run report in other outputs

    Posted Tue May 31, 2022 11:48 AM
    Hi Patrick,

    I already have looked in this documentation too.

    But I was hoping that anyone wrote a code that make this action.

    I remember that I wrote a code to non-interactive mode, it was a simple calling to a method.

    Regards.

    ------------------------------
    JEAM COELHO
    Cognos Solution Architect

    LinkedIn: https://www.linkedin.com/in/jeamcoelho/
    ------------------------------