How to use dashboard context in experience view?

experience

#1

Hi,

My dashboard context works perfectly as a Losant dashboard. However, when used as an experience view page, it does not seem to work. the URL is updated correctly in the browser bar when I click on my list of devices but the gauges always show attribute values for the default device.

In my device list on the dashboard I have the URL as: https://app.losant.com/dashboards/5aa5ecbcf45edf00075f9488?ctx[deviceId-0]={{deviceId}} which works correctly. But when the URL is:
https://pmyexperience.onlosant.com/testdashboard?ctx[deviceId-0]={{deviceId}}
it does not seem to work.

Ideas?


Dashboard to change Imperial/Metrics Units
#2

Hi,
The context variable for experience views do not work the same as in dashboards, you’re going to have to pass path parameters down to the context variables.

Let’s start from the beginning. I’ll assume you have made a route called /testdashboard. You’ll need to add a path parameter like /testdashboard/{deviceId} or if you want it to be optional /testdashboard/{?deviceId} to your endpoint. Then in your workflow, for this page, you will need to pass that parameter through to your view on the Endpont Reply Node. For this example, if you to make a custom json object to return as the page data then your json template would look like { "deviceId": {{ data.params.deviceId }} }. Then in your views dashboard, you will want to set your context variable of deviceId-0 to {{ pageData.deviceId }}.

Hope this helps,
Erin


#3

Thanks Erin,

Understood… Just one more question, That would suggest that in my dashboard where I have my device list control that I click on a device to customise the dashboard, the device list URL would be …/testdashboard/?ctx[deviceId-0]={{deviceId}}&ctx[string-0]={{ valueByKey deviceTags ‘Site’ ‘key’ ‘value’ }}.

That would mean that my dashboard context would no longer work outside the user experience page? Ie just as a normal losant dashboard?


#4

That is a great point, one that I have actually never thought of before but you will have to choose which URL to use on the dashboard. My suggestion would be if you want to display the dashboard on the experience page, or if you want people to view the dashboard on Losant. If you want it on the experience page then use the experience pages URL otherwise use the one we discussed earlier.

We will try to figure out an easy way to allow you to switch back in forth between URLs like this, but currently, we do not have a helper that does what you are asking.

Thanks,
Erin


#5

I’m hitting this issue as well. Device List Block works fine as Losant Dashboard but will not operate correctly as an experience view. If I am reading this thread correctly, there is no way to code a device list block such that it will operate correctly both as a Losant Dashboard or from within an experience view?

I am stumped with this situation. How practically can a dashboard be developed using Losant dashboard and also deployed to an experience view?


#6

Hello! Please I need your help. I’m trying to do this, but I can’t get the dashboard take the new parameter for change the device … where does the dashboard take the new parameter into the context variable? I can only select the devices that I have created but will not let me reference {{pageData.deviceId}} I really sorry, maybe it’s easy but for me it’s not evident…

Thank you!


#7

Hello,

This text input can be a bit tricky, if you have typed the name, also check that you are clicking on the value that comes up, as you must select it as well. Here is how it will appear when correctly selected:

If you are still unable to reference the deviceId, let me know and we will look again!

Thanks,
Julia


#8

Thks! works! your help is wonderful!