Search code examples
iccube

IcCube - accessing Report Code with Javascript


When I am editing a report, I can click on "Report Code" to see information about the report structure. It loks like this:

{
"classID": "ic3.ReportGuts",
"guts_": {
    "ic3Version": 12,
    "schemaName": "test_schema",
    "cubeName": "Cube",
    "layout": {
        "classID": "ic3.FixedLayout",
        "guts_": {
            "ic3Version": 12,
            "grid": 10,
            "boxes": [
                {
                    "classID": "ic3.FixedLayoutBox",
                    "guts_": {
                        "ic3Version":...

How can I access this Information with Javascript? context.$report apparently doesn't give this information.

Also is there a way to get the information, what MDX statements are used in the different charts of a report? And can this be altered with Javascript?


Solution

  • To get report guts add this code to the Report Code:

    function consumeEvent( context, event ) {                                
      if (event.name == 'ic3-report-init') {                                 
        console.log(event.value.state.report);
      }                                                                      
    }
    

    As for handling mdx request before send, it's kinda harder. Again in ReportCode:

    function consumeEvent( context, event ) {                                
       if (event.name == 'ic3-report-init') {       
        event.value.widgetMgr().forEach(function(idx,item){
            if(item.hasOwnProperty('onVizBeforeRequestSend')){
                return;
            }
    
            var oldMethod = item.onVizBeforeRequestSend.bind(item);
            item.onVizBeforeRequestSend = function(request){
                console.log(item, request);
                oldMethod(request);
            }
        });
    }
    

    In this function item is widgetAdapter with info about the widget and request is request instance.