# Any way to get list of all triggers?

**URL:** <https://discourse.nodered.org/t/any-way-to-get-list-of-all-triggers/65014>\
**Category:** General\
**Created:** [12 July 2022 18:34 UTC](https://discourse.nodered.org/t/any-way-to-get-list-of-all-triggers/65014 "2022-07-12T18:34:50Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![MyRandomThoughts](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/myrandomthoughts/32/41085_2.png) [@MyRandomThoughts](https://discourse.nodered.org/u/MyRandomThoughts)\
**Post date:** [12 July 2022 18:34 UTC](https://discourse.nodered.org/t/any-way-to-get-list-of-all-triggers/65014/1 "2022-07-12T18:34:50Z")

</div>

I have a lot of triggers. Some just run once, others every set time interval. Is there a way of getting a list of all these triggers and showing when they fire?

My initial thought would be to parse the `flows.json` file and grab the data from there. Is there a better way?

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [12 July 2022 19:01 UTC](https://discourse.nodered.org/t/any-way-to-get-list-of-all-triggers/65014/2 "2022-07-12T19:01:07Z")

</div>

What types of triggers are you referring to? Is that a particular node type you are using? Or are you using that as a general term for how your flows are started?

---

<div class="post-metadata">

**Author:** ![MyRandomThoughts](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/myrandomthoughts/32/41085_2.png) [@MyRandomThoughts](https://discourse.nodered.org/u/MyRandomThoughts)\
**Post date:** [14 July 2022 07:41 UTC](https://discourse.nodered.org/t/any-way-to-get-list-of-all-triggers/65014/3 "2022-07-14T07:41:50Z")

</div>

Sorry, I should use the proper name! The inject nodes.  
I use them as triggers, so that's what I got used to calling them 🙂

---

<div class="post-metadata">

**Author:** ![rxdeath](https://avatars.discourse-cdn.com/v4/letter/r/67e7ee/32.png) [@rxdeath](https://discourse.nodered.org/u/rxdeath)\
**Post date:** [14 July 2022 07:50 UTC](https://discourse.nodered.org/t/any-way-to-get-list-of-all-triggers/65014/4 "2022-07-14T07:50:52Z")

</div>

this might be stupid, but here's my solve for stuff like this

ctrl+F on the backend  
type 'inject' in and you should get a list of all of them

you can also search inside of function nodes using this, which has been a debugging lifesaver for me

it doesn't show 'when they fire' though, but maybe this is a good start

ps- i name my (i call them triggers too) inject nodes so they tell me how long between repeats ie: 10 sec trigger) or just once (reset flow variables)

---

<div class="post-metadata">

**Author:** ![chrisn-au](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/chrisn-au/32/25504_2.png) [@chrisn-au](https://discourse.nodered.org/u/chrisn-au)\
**Post date:** [14 July 2022 09:14 UTC](https://discourse.nodered.org/t/any-way-to-get-list-of-all-triggers/65014/5 "2022-07-14T09:14:25Z")

</div>

You could use the admin API and retrieve the details

I created this trivial flow

 ![Screen Shot 2022-07-14 at 7.06.40 pm](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/9/09e3b2024f1fcb58b386b2666e0c419e092cd128.png)

```auto
[
    {
        "id": "4c65c2239626cd4b",
        "type": "inject",
        "z": "5a088fb39c10237a",
        "name": "Trigger",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "300",
        "crontab": "",
        "once": true,
        "onceDelay": 0.1,
        "topic": "",
        "payloadType": "date",
        "x": 210,
        "y": 2280,
        "wires": [
            [
                "70ccc2a69aaf2bf0"
            ]
        ]
    },
    {
        "id": "70ccc2a69aaf2bf0",
        "type": "http request",
        "z": "5a088fb39c10237a",
        "name": "Get flows",
        "method": "GET",
        "ret": "obj",
        "paytoqs": "ignore",
        "url": "localhost:1880/flows",
        "tls": "",
        "persist": false,
        "proxy": "",
        "authType": "",
        "senderr": false,
        "x": 430,
        "y": 2280,
        "wires": [
            [
                "946dd11ca12996c0"
            ]
        ]
    },
    {
        "id": "97a4cf26b852bf9d",
        "type": "debug",
        "z": "5a088fb39c10237a",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "x": 830,
        "y": 2280,
        "wires": []
    },
    {
        "id": "946dd11ca12996c0",
        "type": "function",
        "z": "5a088fb39c10237a",
        "name": "Filter only ",
        "func": "const injectNodes = msg.payload.filter((element) => element.type == \"inject\" )\nconst tabs = msg.payload.filter((element) => element.type == \"tab\" )\n\nconst injectNodeList = []\n\ninjectNodes.forEach((node) => {\n const tab = tabs.find((tab) => tab.id == node.z )\n const inject = node\n inject.name = node.name != \"\" ? node.name : \"blank\"\n inject.tab = tab.label\n injectNodeList.push(inject)\n})\nmsg.injectNodes = injectNodes\nmsg.injectNodeList = injectNodeList\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 640,
        "y": 2280,
        "wires": [
            [
                "97a4cf26b852bf9d"
            ]
        ]
    }
]

```

It would return an array of objects like

```auto
{"id":"4c65c2239626cd4b","type":"inject","z":"5a088fb39c10237a","name":"Trigger","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"300","crontab":"","once":true,"onceDelay":0.1,"topic":"","payloadType":"date","x":210,"y":2280,"wires":[["70ccc2a69aaf2bf0"]],"tab":"CSV Load"}

```

---

<div class="post-metadata">

**Author:** ![KarolisL](https://avatars.discourse-cdn.com/v4/letter/k/a4c791/32.png) [@KarolisL](https://discourse.nodered.org/u/KarolisL)\
**Post date:** [14 July 2022 10:13 UTC](https://discourse.nodered.org/t/any-way-to-get-list-of-all-triggers/65014/6 "2022-07-14T10:13:01Z")

</div>

instead of

```auto
    inject.tab = tab.label

```

should be

```auto
    inject.tab = node.label

```

otherwise I'm getting: _"TypeError: Cannot read property 'label' of undefined"_

---

<div class="post-metadata">

**Author:** ![chrisn-au](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/chrisn-au/32/25504_2.png) [@chrisn-au](https://discourse.nodered.org/u/chrisn-au)\
**Post date:** [14 July 2022 10:37 UTC](https://discourse.nodered.org/t/any-way-to-get-list-of-all-triggers/65014/7 "2022-07-14T10:37:59Z")

</div>

Interesting - while I am not checking tab exists I am not sure why it does not

regardless, If I was going to change the code it would be to

```auto
inject.tab = tab != null ? tab.label : "no tab label"

```

---

<div class="post-metadata">

**Author:** ![MyRandomThoughts](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/myrandomthoughts/32/41085_2.png) [@MyRandomThoughts](https://discourse.nodered.org/u/MyRandomThoughts)\
**Post date:** [14 July 2022 10:49 UTC](https://discourse.nodered.org/t/any-way-to-get-list-of-all-triggers/65014/8 "2022-07-14T10:49:31Z")

</div>

That's awesome, thanks.  
I'll have a play and dump it into a pretty table 🙂

---

<div class="post-metadata">

**Author:** ![MyRandomThoughts](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/myrandomthoughts/32/41085_2.png) [@MyRandomThoughts](https://discourse.nodered.org/u/MyRandomThoughts)\
**Post date:** [14 July 2022 14:44 UTC](https://discourse.nodered.org/t/any-way-to-get-list-of-all-triggers/65014/9 "2022-07-14T14:44:26Z")

</div>

Using @chrisn-au example and the table node from `node-red-node-ui-table` I have put together a little display that I may still tweak with, but looks OK so far. You'll also need the cronstrue npm module for the human readable timings.

 ![triggerlist](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/1/2145580949f34278b2b7093eeb17d61fba414c48.png)

`[{"id":"4c65c2239626cd4b","type":"inject","z":"da204325.2b65f","name":"Get Triggers","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[]","payloadType":"json","x":130,"y":260,"wires":[["70ccc2a69aaf2bf0","0b3b8f8728bf56eb"]]},{"id":"70ccc2a69aaf2bf0","type":"http request","z":"da204325.2b65f","name":"Get flows","method":"GET","ret":"obj","paytoqs":"ignore","url":"localhost:1880/flows","tls":"","persist":false,"proxy":"","authType":"","senderr":false,"x":320,"y":280,"wires":[["946dd11ca12996c0"]]},{"id":"946dd11ca12996c0","type":"function","z":"da204325.2b65f","name":"Filter only ","func":"function nodeType(node) {\n return ((node.type == \"inject\") || (node.type == \"cronplus\"))\n}\nconst injectNodes = msg.payload.filter(nodeType);\nconst injectNodeList = [];\n\ninjectNodes.forEach((node) => {\n const inject = node;\n inject.name = node.name != \"\" ? node.name : \"blank\";\n injectNodeList.push(inject);\n})\n\n//msg.injectNodes = injectNodes\nmsg.injectNodeList = injectNodeList;\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":480,"y":280,"wires":[["14a8b8bde7b3cb2b"]]},{"id":"14a8b8bde7b3cb2b","type":"function","z":"da204325.2b65f","name":"Parse Data","func":"//const cronstrue = require('cronstrue');\n\nmsg.injectNodeList.forEach(item => {\n var linksTo = [];\n\n if (item.wires) {\n (item.wires[0]).forEach(linkOut => {\n const foundOut = msg.payload.find((foundOut) => foundOut.id == linkOut);\n\n if (foundOut.type === \"link out\") {\n (foundOut.links).forEach(linkIn => {\n const foundIn = msg.payload.find((foundIn) => foundIn.id == foundOut);\n linksTo.push(`[L] ${foundOut.name}`);\n })\n }\n else {\n linksTo.push(`[N] ${foundOut.name}`);\n }\n })\n }\n\n var cronString = \"\";\n if (item.options) { item.crontab = item.options[0].expression }\n if (item.crontab) {\n cronString = cronstrue.toString(item.crontab, {use24HourTimeFormat: true, monthStartIndexZero: true});\n }\n\n node.send({\n \"payload\":{\n name: item.name,\n once: item.once,\n delay: item.oncedelay,\n repeat: item.repeat,\n crontab: cronString,\n n: linksTo.length,\n linksTo: linksTo\n }\n });\n});\n\nnode.done;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[{"var":"cronstrue","module":"cronstrue"}],"x":650,"y":280,"wires":[["ae065a9af46dba6f"]]},{"id":"ae065a9af46dba6f","type":"join","z":"da204325.2b65f","name":"Join","mode":"custom","build":"array","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"1","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":810,"y":280,"wires":[["7d0dfd0e0757cca2"]]},{"id":"7d0dfd0e0757cca2","type":"ui_table","z":"da204325.2b65f","group":"cdb12a338f126946","name":"Trigger List","order":0,"width":"24","height":"19","columns":[],"outputs":0,"cts":false,"x":990,"y":240,"wires":[]},{"id":"0b3b8f8728bf56eb","type":"change","z":"da204325.2b65f","name":"Format Columns","rules":[{"t":"set","p":"ui_control","pt":"msg","to":"{\"tabulator\":{\"layout\":\"fitDataFill\"}}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":340,"y":240,"wires":[["7d0dfd0e0757cca2"]]},{"id":"cdb12a338f126946","type":"ui_group","name":"Testing","tab":"cf15d7badfb5510b","order":2,"disp":true,"width":"24","collapse":false,"className":""},{"id":"cf15d7badfb5510b","type":"ui_tab","name":"Testing","icon":"dashboard","order":11,"disabled":false,"hidden":false}]`

---

<div class="post-metadata">

**Author:** ![chrisn-au](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/chrisn-au/32/25504_2.png) [@chrisn-au](https://discourse.nodered.org/u/chrisn-au)\
**Post date:** [14 July 2022 20:31 UTC](https://discourse.nodered.org/t/any-way-to-get-list-of-all-triggers/65014/10 "2022-07-14T20:31:48Z")

</div>

The admin API is pretty cool, great to see it worked for you, actually, you have solved an issue I didn't even know I had. A nice way to get the data on what is been injected - Just need to make sure we name nodes nicely - 🙂

---

<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:** [12 September 2022 20:32 UTC](https://discourse.nodered.org/t/any-way-to-get-list-of-all-triggers/65014/11 "2022-09-12T20:32:10Z")

</div>

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