I am trying to pass a context variable into a dashboard and into an HTML block of dashboard, as you can see in the screenshot attached, I can get my ctx variable in the title of my HTML Block but cant pass inside the HTML Block.
Specifically, you want to take a look at the section around the DashboardBlock global.
Within the context of your page, there will be a global JavaScript object called DashboardBlock available. It exposes several events that can be subscribed to from your custom JavaScript in order to receive your query data (among other things).
You can subscribe to events using the following syntax: DashboardBlock.on(âeventNameâ, myCustomFunction) . All events are emitted on the initial block load and then again whenever the specific action occurs.
I was hoping you can also help on this one, I have a HTML Block that I am using to display snapshots that I have stored in AWS S3, in order to display this information on my vibration sensor dashboard, I will need the serial number of my sensor which also is a context variable that I am allowed to display on my Dashboard blocks titles but canât have it inside my HTML block precisely in the javascript code, The screenshots attached shows the snapshot section of my dashboard, you can see the HTML Block giving the user ability to select 2 dates and then click on the button âShow Snapshotâ.
Hope you can give us advise on any approach that could help us get the serial number inside the HTML Block javascript code in order to get our snapshots related to the sensor in question.
PS: we have used before a workflow to include information such as Serial Number in our pages using the code below, but I am not sure if it is something that can help us
There is nothing additional that you need to add to the head section of the Custom HTML block
Our documentation, though, explains that you can access Context Variables with DashboardBlock.ctx.<variableName>. The way in which you utilize this value is totally up to you!
You can also use console.log(DashboardBlock) to see all that is available to you when using the Custom HTML Block.
Thanks @Heath, despite reading the doc I was looking for a solution too.
In my case I had to use DashboardBlock.input.ctx.<variableName> in order to display the context variable.