# Get xtrigger name from task that was triggered?

**URL:** <https://cylc.discourse.group/t/get-xtrigger-name-from-task-that-was-triggered/926>\
**Category:** Cylc Support\
**Created:** [March 24, 2024, 10:15pm UTC](https://cylc.discourse.group/t/get-xtrigger-name-from-task-that-was-triggered/926 "2024-03-24T22:15:15Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![TomC](https://yyz2.discourse-cdn.com/free1/user_avatar/cylc.discourse.group/tomc/32/115_2.png) [@TomC](https://cylc.discourse.group/u/TomC)\
**Post date:** [March 24, 2024, 10:15pm UTC](https://cylc.discourse.group/t/get-xtrigger-name-from-task-that-was-triggered/926/1 "2024-03-24T22:15:15Z")

</div>

Is there a way to get the xtrigger name in a task?

For example, `UPSTREAM_STARTED_ECMWF` and various other centres. They all trigger different tasks, and provide information as variables from the xtrigger. It would be handy to be able to just do, in a shell script

```bash
a=UPSTREAM_STARTED_ECMWF_data
data=${!a}

```

Rather than eiher pass in `UPSTREAM_STARTED_ECMWF` (or `UPSTREAM_STARTED` and infer `ECMWF` from the task name), or hardcode anything else in.

I thought it might have had something like the `CYLC_TASK_NAMESPACE_HIERARCHY` for xtriggers, but I couldn’t see anything in the `job` script.

The basic idea of asking this is because it would be useful for portability of some scripts between different workflows which have the same basic pattern, but perhaps different xtrigger names.

---

<div class="post-metadata">

**Author:** ![hilary.j.oliver](https://yyz2.discourse-cdn.com/free1/user_avatar/cylc.discourse.group/hilary.j.oliver/32/4_2.png) [@hilary.j.oliver](https://cylc.discourse.group/u/hilary.j.oliver)\
**Post date:** [March 24, 2024, 11:41pm UTC](https://cylc.discourse.group/t/get-xtrigger-name-from-task-that-was-triggered/926/2 "2024-03-24T23:41:02Z")

</div>

Can you post an issue on the cylc-flow repository for that? I think it could be useful, and easily implemented - Cylc could automatically add the xtrigger name to the dict of results returned from the function.

For now, you could modify the xtrigger function source, and get it to return its own name in the results dict.

(I presume you mean the actual function name, not the short trigger name used in the graph?)
