Get current report parameters

torajapan
edited February 11, 2022 in Analytics #1

Hello,

I am trying to create an HTML button that refreshes a report page. My code has been:

this.onclick = function(event)
{
var viewer = this.getViewer();
viewer.submit();
}

However, that seems to revert the report to its default parameters, and not the report parameters chosen by the user. I see that the viewer has a setParameters function, but I don't know how to get the parameters from the report. My pseudo-code would be:

this.onclick = function(event)
{
var viewer = this.getViewer();
var params = get current report parameters;
viewer.setParameters(params);
viewer.submit();
}

I just don't know how to get the current report parameters to make this work.

Thanks!

Comments

  • This would help me, as well. I think I'd be more interested in variables, but how to access (read and write) parameters and variables in javascript callbacks. The 'params' and 'vars' objects don't seem to be available, and I can't seem to locate the reportContext object, assuming that's the key to this.

  • The OT support team came up with a workaround (not what I would call elegant, but serviceable)

    • For each parameter (or variable, although I don't know how to use those or how they are different from params), add a hidden text item in the report, for example params["Group"].value' />

    • Define the Refresh button with a code like the below:

    this.onclick = function(event)
    {
    this.getViewer().setParameters({Group:document.getElementById("Group").value});
    this.getViewer().submit(null, true);
    }

    Hope this helps!