Good morning. I am contacting you to see if you can help me with sending data from a dashboard to workflows via webhook (or endpoint).
Specifically, my idea is a Custom HTML block that allows you to download data in CSV from a device through the Losant API node, using the Data:Export option. The part related to the Losant node is solved.
My Custom HTML block looks like this:
I have no problem in selecting start date and end date in relation to when the data should be downloaded, as well as the email where this data should be sent to. My problem comes at the time of indicating the device Id in its corresponding box (Current Device dropdown option should have assigned the value of the deviceID the dashboard is currently showing, due to the deviceID is a ctx variable). I attach a screenshot in relation to the HTML code where I think it will be better understood what my problem is.
I have been playing with the Custom HTML block and the code that comes by default, and the maximum that I have obtained is that the content of the JSON appears on the screen. However, I have been unable to send the id of this JSON content through HTML using:
<option value="EXTRACT IN SOME WAY THE ID OF THE JSON">Current Device</option>.
My problem, in conclusion, is to know how to extract from the dashboard context the id of the current device (the one being queried) and put this value in the “value” field of an HTML element, in order to send it through a webhook.
The code that I’m using right now in the Custom HTML Block is:
<div class="container-fluid"> <div class="row"> <div class="col"> <form action="https://triggers.losant.com/webhooks/xTN5VtSfrjMWM5-YpxHqQ-f69FJFc99eifvbXXFq" method="post"> <div> Select start day: <input class="input-group date" type="date" id="start" name="date-start"> </div><br> <div> Select end day: <input class="input-group date" type="date" id="end" name="date-end"> </div><br> <label> Select device:</label> <select class="form-control" name="numberDevices"> <option value = "0">Current Device</option> <option value="1">All Devices</option> </select><br> <label id="blockInput"></label> <div> <label for="email">Email address:</label> <input type="email" class="form-control" name="email" id="email" placeholder="e.g. email@example.com"> </div><br> <button type="submit" class="btn btn-success pull-right">Download CSV File</button> </form> </div> </div> </div>
Finally, the idea is sending this data using a Webhook so the received body will be:
where numberDevices would be the ID of the device so you can use it as an input in the Losant API node.
Any help would be greatly appreciated. Thanks in advance, greetings