Communication with Embedded KPI Dashboards

Content:

When you embed KPI Dashboards (see Embed a KPI Dashboard), you can set up receiving messages from the dashboard to your application.

In GoodData, terms workspace and project denote the same entity. For example, project ID is exactly the same as workspace ID.

Supported events and commands

Commands are incoming messages sent from your application to the embedded KPI Dashboard to apply actions.

Events are outgoing messages that the embedded KPI Dashboard send to you application to notify about the status of commands (for example, success or failure). Events are sent automatically.

ContextId is used to correlate events and commands. It identifies the input and output of the communication.

Events

EventEvent trigger
loadingStarted

The embedded content starts loading.

{
    "gdc": {
        "product": "dashboard",
        "event": {
            "name": "loadingStarted",
            "contextId": "context123"
        }
    }
}
loaded

The content is fully loaded, and the user has permissions to access the dashboard.

{
    "gdc": {
        "product": "dashboard",
        "event": {
            "name": "loaded",
            "contextId": "context123"
        }
    }
}
noPermissions

The user does not have permissions to view or edit the content. The 'data' section contains information about whether view or edit permissions are missing.

Possible reason values: viewDenied and editDenied.

{
    "gdc": {
        "product": "dashboard",
        "event": {
            "name": "noPermissions",
            "data": {
                "reason": "viewDenied"
            },
            "contextId": "context123"
        }
    }
}
resized

An operation increasing the height of the hosting iframe is performed. The 'data' section contains information what height the iframe needs (in pixels).

{
    "gdc": {
        "product": "dashboard",
        "event": {
            "name": "resized",
            "data": {
                "height": 600 // Height in px
            },
            "contextId": "context123"
        }
    }
}
dashboardCreated

A dashboard has been created and saved. The 'data' section contains, among other information, the dashboard ID. You can store it on your side and use later for managing multiple dashboards for this particular user.

{
    "gdc": {
        "product": "dashboard",
        "event": {
            "name": "dashboardCreated",
            "data": {
                "project": "project_id",
                "client": "client_id",
                "dashboard": "dashboard_identifier",
                "dashboardId": "dashboard_id"
            }
            "contextId": "context123"
        }
    }
}
dashboardCreationCanceled

The user cancels the creation of the dashboard.

{
    "gdc": {
        "product": "dashboard",
        "event": {
            "name": "dashboardCreationCanceled",
            "contextId": "context123"
        }
    }
}
dashboardUpdated

The existing dashboard has been updated. The 'data' section contains, among other information, the dashboard ID. You can store it on your side and use later for managing multiple dashboards for this particular user.

{
    "gdc": {
        "product": "dashboard",
        "event": {
            "name": "dashboardUpdated",
            "data": {
                "project": "project_id",
                "client": "client_id",
                "dashboard": "dashboard_identifier",
                "dashboardId": "dashboard_id"
            }
            "contextId": "context123"
        }
    }
}
dashboardDeleted

The dashboard has been deleted. The 'data' section contains information about the deleted dashboard.

{
    "gdc": {
        "product": "dashboard",
        "event": {
            "name": "dashboardDeleted",
            "data": {
                "project": "project_id",
                "client": "client_id",
                "dashboard": "dashboard_identifier",
                "dashboardId": "dashboard_id"
            }
            "contextId": "context123"
        }
    }
}
platform

The GoodData platform is temporary unavailable.

Possible status values: maintenance, upgrade, or error.

{
    "gdc": {
        "product": "dashboard",
        "event": {
            "name": "platform",
            "data": {
                "status": "maintenance"
            }
            "contextId": "context123"
        }
    }
}

For the status of 'error', the 'data' section contains additional error details.

{
    "gdc": {
        "product": "dashboard",
        "event": {
            "name": "platform",
            "data": {
                "status": "error",
                "errorCode": 500,
                "description": "Internal server error"
            }
            "contextId": "context123"
        }
    }
}
setFilterContextFinished

A confirmation that the filters that you sent have been applied.

{
    "gdc": {
        "product": "dashboard",
        "event": {
            "name": "setFilterContextFinished",
            "contextId": "context123"
        }
    }
}
setFilterParentsFinished

A confirmation that the filters that you sent have been applied.

{
    "gdc": {
        "product": "dashboard",
        "event": {
            "name": "setFilterParentsFinished",
            "contextId": "context123"
        }
    }
}
filterContextChanged

A set of filters has been changed. Includes the new definitions of all filters that have been changed.

{
    "gdc": {
        "product": "dashboard",
        "event": {
            "name": "filterContextChanged",
            "data": {
                "filters": [
                    {
                        "relativeDateFilter": {
                            "dataSet": {
                                "identifier": "identifier 123"
                            },
                            "granularity": "GDC.time.date",
                            "from": -6,
                            "to": 0
                        },
                    }
                ]
            },
            "contextId": "context123"
        }
    }
}
setFilterParentsFailed

Failed command if you try to connect a child filter to the parent filter.

{
    "gdc": {
        "product": "dashboard",
        "event": {
            "name": "setFilterParentsFailed",
            "data": {
                "errorCode": "circularDependency"
            },
            "contextId": "setFilterParents-1601932858809"
        }
    }
}

List of possible errors:

  • invalidDataFormat - The command data format is invalid. For example, there are missing properties or wrong types.
  • invalidAttributeFilterDisplayForm - The attribute filter display form has an invalid reference or the display form does not exist in the workspace.
  • invalidParentFilterDisplayForm - The parent filter display form has an invalid reference or does not exist in the workspace.
  • filterNotFound - The filter is not on the dashboard.
  • circularDependency - The filter can not depend on itself.
  • invalidConnectingAttribute - The connecting attribute is invalid or does not exist in the workspace.
  • incompatibleConnectingAttribute - The connecting attribute is not shared between the filter and its parent.
  • duplicateFilters - Multiple filters with the same id in a single command.
  • duplicateParents - Multiple parents with the same id in a single filter.
drillToUrlStarted

Drilling to a URL address starts. The message contains the ID of the window.

You must enable the redirect-drill-url-to-message=all in the embedded mode URL. If not enabled, no postMessages are sent and drilling is managed by the application.

{
    "gdc": {
        "product": "dashboard",
        "event": {
            "name": "drillToUrlStarted",
            "data": {
                "id": "windowId123"
            },
            "contextId": "context123"
        }
    }
}
drillToUrlResolved

Contains the window ID and the target URL that opens in the specified tab/window.

You must enable the redirect-drill-url-to-message=all in the embedded mode URL. If not enabled, no postMessages are sent and drilling is managed by the application.

{
    "gdc": {
        "product": "dashboard",
        "event": {
            "name": "drillToUrlResolved",
            "data": {
                "id": "windowId123"
                "url": "https://yourdomain"
            },
            "contextId": "context123"
        }
    }
}

Commands

CommandCommand trigger
switchToEdit

Opens the KPI Dashboard for editing (in view mode only).

{
    "gdc": {
        "product": "dashboard",
        "event": {
            "name": "switchToEdit",
            "contextId": "context123"
        }
    }
}
cancelEdit

Closes the KPI Dashboard (in edit mode only).

{
    "gdc": {
        "product": "dashboard",
        "event": {
            "name": "cancelEdit",
            "contextId": "context123"
        }
    }
}
addWidget

Adds an item to the KPI Dashboard (in edit mode only).

Example: Add insight

{
    "gdc": {
        "product": "dashboard",
        "event": {
            "name": "addWidget",
            "data": {
                "widget": {
                    "type": "insight",
                    "ref": {
                        "identifier": "aadFXtJKdz2k" // identifier or uri
                    }
                }
            },
            "contextId": "context123"
        }
    }
}

Example: Add a KPI

{
    "gdc": {
        "product": "dashboard",
        "event": {
            "name": "addWidget",
            "data": {
                "widget": {
                    "type": "kpi"
                }
            },
            "contextId": "context123"
        }
    }
}
addFilter

Add a filter to the KPI Dashboard (in edit mode only).

{
    "gdc": {
        "product": "dashboard",
        "event": {
            "name": "addFilter",
            "contextId": "context123"
        }
    }
}
setFilterContext

Applies a set of filters to the embedded KPI Dashboard. You can define, one or more filters in the filter definition.

When the received filter configuration is applied, the following happens:

  • The filter configuration overrides any filters that the dashboard may already have, such as existing attribute and date filters, URL filters, previous filter configuration, and so on.

  • The filter configuration is applied even if the dashboard does not yet have any filters at all.
  • The filter configuration takes into account existing user permissions or variable filters: if they restrict some filters or filter values in the received configuration, those filters and values are not applied.
{
    "gdc": {
        "product": "dashboard",
        "event": {
            "name": "setFilterContext",
            "data": {
                "filters": [
                    {
                        "positiveAttributeFilter": {
                            "displayForm": {
                                "identifier": "identifier123"
                            },
                            "in": [
                                "/gdc/md/kr3t3bca94asl/obj/400/elements?id=12"
                            ]
                        }
                    }
                ],
            },
            "contextId": "context123"
        }
    }
}

Notes:

  • To add a new filter, you must be in the Edit mode.
  • You can add max. 20 filters
  • If you receive an error, no filter from the postMessage is applied.

Example: Attribute filter - using an identifier

{
    "positiveAttributeFilter": {
        "displayForm": {
            "identifier": "identifier123"
        },
        "in": [
            "/gdc/md/kr3t3bca94asl/obj/400/elements?id=12"
        ]
    }
}

Example: Attribute filter - using URI

{
    "positiveAttributeFilter": {
        "displayForm": {
            "uri": "/gdc/md/kr3t3bca94asl/obj/399"
        },
        "in": [
            "/gdc/md/kr3t3bca94asl/obj/400/elements?id=12"
        ]
    }
}

Example: Negative attribute filter

{
    "positiveAttributeFilter": {
        "displayForm": {
            "identifier": "identifier123"
        },
        "notIn": [
            "/gdc/md/kr3t3bca94asl/obj/400/elements?id=12"
        ]
    }
}

Example: Attribute filter with all values

{
    "positiveAttributeFilter": {
        "displayForm": {
            "identifier": "identifier123"
        },
        "notIn": []
    }
}

Example: Absolute date filter

{
    "absoluteDateFilter": {
        "dataSet": {
            "identifier": "identifier123"
        },
        "from": "2017-01-01",
        "to': "2017-12-31"
    },
}

Example: Relative date filter

You can use the following granularities: GDC.time.week_us, GDC.time.month, GDC.time.year, GDC.time.quarter, GDC.time.date.

{
    "relativeDateFilter": {
        "dataSet": {
            "identifier": "identifier 123"
        },
        "granularity": "GDC.time.date",
        "from": -6,
        "to": 0
    },
}

Example: All time date filter

{
    relativeDateFilter: {
        dataSet: {
            identifier: "identifier123",
        },
        granularity: "ALL_TIME_GRANULARITY",
        from: 0,
        to: 0,
    }
}

Example: Ranking filter

Although the ranking filter is supported by the interface of setFilterContext , KPI Dashboard does not support this filter and it results in error. See Embed Analytical Designer.

removeFilterContext

Removes filters from the embedded KPI Dashboards (in edit mode only).

{
    "gdc": {
        "product": "dashboard",
        "event": {
            "name": "removeFilterContext",
            data: {
                filters: [
                    // attribute filter
                    {
                        displayForm: {
                            identifier: "identifier123"
                        }
                    },
                    // date filter
                    {
                        dataSet: {
                            identifier: "identifier123"
                        }
                    },
                ],
            },
            "contextId": "context123"
        }
    }
}
setFilterParents

Applies a hierarchy among attribute filters on a KPI Dashboard (in edit mode only).

{
    "gdc": {
        "product": "dashboard",
        "event": {
            "name": "setFilterParents",
            "data": {
                "filters": [
                    {
                        "filter": {
                            "attributeFilter": {
                                "displayForm": {
                                    "uri": "/gdc/md/ux8xk21n3al4qr1akoz7j6xkl5dt1dqj/obj/102844"
                                }
                            }
                        },
                        "parents": [
                            {
                                "parent": {
                                    "attributeFilter": {
                                        "displayForm": {
                                            "uri": "/gdc/md/ux8xk21n3al4qr1akoz7j6xkl5dt1dqj/obj/1028"
                                        }
                                    }
                                },
                                "connectingAttribute": {
                                    "uri": "/gdc/md/ux8xk21n3al4qr1akoz7j6xkl5dt1dqj/obj/1025"
                                }
                            }
                        ]
                    }
                ]
            },
            "contextId": "setFilterParents-1601932858809"
        }
    }
}

Example: Remove all parent filters

{
    "gdc": {
        "product": "dashboard",
        "event": {
            "name": "setFilterParents",
            "data": {
                "filters": [
                    {
                        "filter": {
                            "attributeFilter": {
                                "displayForm": {
                                    "uri": "/gdc/md/ux8xk21n3al4qr1akoz7j6xkl5dt1dqj/obj/1028"
                                }
                            }
                        },
                        "parents": []
                    }
                ]
            },
            "contextId": "setFilterParents-1601932858809"
        }
    }
}
openScheduleEmailDialog

Opens a dialog for scheduling emails for the current dashboard (in view mode only).

{
    "gdc": {
        "product": "dashboard",
        "event": {
            "name": "openScheduleEmailDialog",
            "contextId": "context123"
        }
    }
}
Powered by Atlassian Confluence and Scroll Viewport.