# Trigger an event by calling the dashboard

**URL:** <https://discourse.nodered.org/t/trigger-an-event-by-calling-the-dashboard/33958>\
**Category:** Dashboard\
**Created:** [8 October 2020 16:54 UTC](https://discourse.nodered.org/t/trigger-an-event-by-calling-the-dashboard/33958 "2020-10-08T16:54:39Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![edstobi](https://avatars.discourse-cdn.com/v4/letter/e/aca169/32.png) [@edstobi](https://discourse.nodered.org/u/edstobi)\
**Post date:** [8 October 2020 16:54 UTC](https://discourse.nodered.org/t/trigger-an-event-by-calling-the-dashboard/33958/1 "2020-10-08T16:54:39Z")

</div>

hello  
can i trigger an event by calling the dashboard specified group to log when the page was called or to read and display a current value from the database by opening that group?  
THX

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [8 October 2020 17:03 UTC](https://discourse.nodered.org/t/trigger-an-event-by-calling-the-dashboard/33958/2 "2020-10-08T17:03:43Z")

</div>

When the page was loaded - yes, you can use the ui control node for that I think. Not sure about when opening a tab if that's what you meant.

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [8 October 2020 17:45 UTC](https://discourse.nodered.org/t/trigger-an-event-by-calling-the-dashboard/33958/3 "2020-10-08T17:45:06Z")

</div>

Yes ui\_control will report

- `payload` - _connect_ , _lost_ , _change_ , or _group_ .
- `socketid` - the ID of the socket (this will change every time the browser reloads the page).
- `socketip` - the ip address from where the connection originated.
- `tab` - the number of the tab. (only for 'change' event).
- `name` - the name of the tab. (only for 'change' event).
- `group` - the name of the group. (only for 'group' event).
- `open` - the state of the group. (only for 'group' event).

---

<div class="post-metadata">

**Author:** ![SuperNinja](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/superninja/32/5761_2.png) [@SuperNinja](https://discourse.nodered.org/u/SuperNinja)\
**Post date:** [8 October 2020 19:11 UTC](https://discourse.nodered.org/t/trigger-an-event-by-calling-the-dashboard/33958/4 "2020-10-08T19:11:17Z")

</div>

I don't know if I understood everything you are asking but here is a flow that tells you the time when a dashboard tab has been opened:  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/c/ec3330722cc7906625759925e8db65e537476b87.png)  
_if you inject "1", you will open tab 1 and tell you what time it was opened..._

```auto
[{"id":"f9b032ae.2bd87","type":"inject","z":"fe2c7bc6.bd49c8","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":"","topic":"","payload":"1","payloadType":"str","x":710,"y":3210,"wires":[["4666aac0.c016f4"]]},{"id":"4666aac0.c016f4","type":"ui_ui_control","z":"fe2c7bc6.bd49c8","name":"change group","events":"change","x":880,"y":3210,"wires":[["7ebcc133.3fcb3","2bb70992.1a6be6","bd09ad5f.9e37b"]]},{"id":"bd09ad5f.9e37b","type":"function","z":"fe2c7bc6.bd49c8","name":"d_h","func":"var hourChange = picHour(new Date());\n\nmsg= [{\n payload: msg.payload,\n tab:msg.tab,\n name:msg.name,\n hourChange: hourChange,\n }]; // set a new \nreturn msg;\n\n//////////////////////// fonction /////////////////////////////\n//========== picHour ==========\nfunction picHour(d) {\nvar hour = d.getHours(); //hour\nhour = hour.toString();\n if (hour < 10) {hour = \"0\"+ hour}\nvar minutes = d.getMinutes();\nminutes = minutes.toString();\n if (minutes < 10) {minutes = \"0\"+ minutes}\nvar secondes = d.getSeconds();\nsecondes = secondes.toString();\n if (secondes < 10) {secondes = \"0\"+ secondes}\nvar time = (hour+':'+ minutes+':'+secondes);//(hour+minutes+secondes);//\nreturn time;\n} // fin de picHour\n\n/*\n\n\n\n*/","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1040,"y":3210,"wires":[["51894f7b.a1e1e"]]},{"id":"51894f7b.a1e1e","type":"debug","z":"fe2c7bc6.bd49c8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":1160,"y":3210,"wires":[]},{"id":"7ebcc133.3fcb3","type":"debug","z":"fe2c7bc6.bd49c8","name":"ui_control","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":1040,"y":3170,"wires":[]}]

```

---

<div class="post-metadata">

**Author:** ![edstobi](https://avatars.discourse-cdn.com/v4/letter/e/aca169/32.png) [@edstobi](https://discourse.nodered.org/u/edstobi)\
**Post date:** [8 October 2020 19:55 UTC](https://discourse.nodered.org/t/trigger-an-event-by-calling-the-dashboard/33958/5 "2020-10-08T19:55:19Z")

</div>

Thanks for the great help.  
I did not know the function of ui\_control yet.  
It makes it even easier for me to get the IP address delivered.  
I still have to understand the function lost, but it is not important for me at the moment.

@SuperNinja thanks for your example.  
Interesting your function. It makes it easier in some points. Also here I did not know that you can write a function in a function.

Today I learned a lot again! THANK YOU  
😊

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [22 October 2020 19:55 UTC](https://discourse.nodered.org/t/trigger-an-event-by-calling-the-dashboard/33958/6 "2020-10-22T19:55:19Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
