Knowledge Drop

How to set an embedded dashboard filter name as a saved variable with JSON.stringify()

Last tested: Dec 24, 2018

When using embedded Javascript events you might use JSON.stringify() to pass a string into the postMessage() function.

Example function that takes in filter and value and tries to pass them into the JSON inside of JSON.stringify()

function updateFilters(filter, value) {

var iframe = document.getElementById('looker');

var update_request = JSON.stringify(


"type": "dashboard:filters:update",

"filters": {

filter : value





"https://{{ domain }}"




This will not work, the value variable will be turned into a value like "Sweaters", but the filter will turn into "filter" and not the name of the filter on the dashboard like "Category"

To get both the key AND the value passed in, we need to add this data into the JSON differently


filter_name = "Category"

var object = {

"type": "dashboard:filters:update",

"filters": {}


object['filters'][filter_name] = value



This will go into the filters hash of object, and then set "Category" = some_value you click on.

Sources:  StackOverflow


This content is subject to limited support.                




0 replies

Be the first to reply!