How pass a context variable as deviceTag

Hi,

I’m trying to pass a context variable (parentId = {{request.query.deviceId}}), through experience, as Device Tag to the dashboard. I found this case in the documentation, where the fields are generated for a specific dashboard (and generates key-value fields for the context of type deviceTag), but in my case the ID of dashboard is dynamic, and I should pass the key and value of the deviceTag in the value field, as shown in the figure, is this possible? And if possible what would be the format?

Or how could I pass that same context, but using {{element ‘dashboard’ dashboardId = pageData.dashboards.dashId ctx = (obj deviceId = request.params.deviceId parentId = ???)}}? I tried to use something like this, but without success.

This topic is similar to I’m trying to solve, but I also haven’t found an answer for the deviceTag use case as a context. Since for the other types of context variable, I can use it normally.

Any suggestion?

@Vander_Maziero,

Yeah, this looks like a hard one to do from within the UI. I’m putting in a ticket for that. However, here is how you would do it using the element helper:

{{ element "dashboard" dashboardId=(template "58ebd885e326860001a6699f") ctx=(obj devId=(template "{{request.query.deviceId}}") deviceTag-0=(obj key=(template "DeviceRecipe") value=(template "{{request.query.value}}"))) theme=(template "light") time=(template "") }}

Thanks @anaptfox this example of use of element solve my problem!

@anaptfox Just another possible bug, if I use only the helper element, with no other characters in the block content, when saved, the page automatically changes the page type from Custom to Dashboard, but if I insert another character, like a space, it doesn’t happen , and the page type remains as custom. Like as in the sequence of images.

  1. Page as Custom, just with helper element

  2. Saved - change to type Dashboard

  3. Page as Custom, caractere space more helper element - save and work

1 Like

So, this exposes a pretty cool thing about Dashboard Pages. Today, behind the scenes, they aren’t a special kind of page. A Dashboard Page is simply a page with only (even down to the spaces) the element helper pointing to a Dashboard. So, that’s why you’re seeing this behavior here.

However, I’m making a ticket about this to improve this experience a bit. :slight_smile: