Experience Link Not Passing Context to Dashboard

Hi,

I have an experience page, showing an overview dashboard, with a device state table listing all devices.

Within the device state table, I have a Device Name, with a cell template of:

[Dashboard] (http://myexperienceaddress.co.uk/devicedashboard?ctx[deviceId-0]={{deviceId}})

My dashboard is setup to be context driven, using deviceId-0

When I click the [Dashboard] links in my state table, this renders my dashboard, with the deviceId in the URL. However the dashboard is only populated with the default context deviceId.

I suspect the issue is subtle and lies within the Endpoint or Page settings in my experience setup, but I’ve now hit the point where I really need some support!

Many thanks!

Combining dashboard context with experience pages can certainly be confusing.

When a dashboard is put inside an experience, you gain full control over how context is provided to that dashboard. The URL syntax, ?ctx[deviceId-0]=id, is what the Losant frontend uses to pass context to a dashboard. You can think of your experience as replacing the Losant frontend, which means you’re also replacing how context variables are passed to the dashboard.

If you do want to directly support that same URL syntax, here’s what your page configuration will look like:

You can see in the Render Log (right side of the screen) how the device ID comes in to your experience when it’s passed in using a query parameter.

The Dashboard Context section is where you provide your dashboard the context it requires. That specific URL syntax results in a key that’s a little hard to use with Handlebars (due to the square brackets), but the template is:

{{ lookup request.query 'ctx[deviceId-0]' }}

In most of my experiences, I don’t use that URL syntax. I’ll usually provide the device ID using an easier query parameter (e.g. ?device=id). This makes the template much easier:

{{request.query.device}}

To see an example of this, check out the Industrial Equipment Monitor application template.

So long story short, when using a dashboard with context inside an experience, you must provide values for each context variable in the Dashboard Context section. Where those values come from is entirely up to you and the experience you’re building.

1 Like