# Use automation step results in automation scripting

**URL:** <https://community.fibery.io/t/use-automation-step-results-in-automation-scripting/4364>\
**Category:** Get Help\
**Created:** [April 23, 2023, 11:23pm UTC](https://community.fibery.io/t/use-automation-step-results-in-automation-scripting/4364 "2023-04-23T23:23:50Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tommy\_Hedley](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/tommy_hedley/32/6468_2.png) [@Tommy\_Hedley](https://community.fibery.io/u/Tommy_Hedley)\
**Post date:** [April 23, 2023, 11:23pm UTC](https://community.fibery.io/t/use-automation-step-results-in-automation-scripting/4364/1 "2023-04-23T23:23:50Z")

</div>

Is it possible to use/call automation step results in scripts?

For example, I have an automation script the triggers when a Material entity is linked to a Box entity. If I create the automation in the Box DB I can get the Box entity info when I use args.currentEntities, but not the Material info. I have the opposite problem if I make the automation in the Materials DB. As a Box entity has many Material entities, I either need to get the Material that triggered the entity or filter all connected entities by most recently added. I’ve attempted filtering with GraphQL queries but haven’t been successful so far. I’ve attached images to show the automation trigger and the entity info.

 ![Box Material Link](https://us1.discourse-cdn.com/flex020/uploads/fibery/original/2X/e/e26f8cbab786a45e8bf627a381ba8ada626b7e1a.png)  
 ![Box Material Link Result](https://us1.discourse-cdn.com/flex020/uploads/fibery/original/2X/f/f43b76c3ae36273800684ba4f53b5d4bcb2a4323.png)

---

<div class="post-metadata">

**Author:** ![gb\_carbone](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/gb_carbone/32/5345_2.png) [@gb\_carbone](https://community.fibery.io/u/gb_carbone)\
**Post date:** [April 25, 2023, 7:27pm UTC](https://community.fibery.io/t/use-automation-step-results-in-automation-scripting/4364/2 "2023-04-25T19:27:17Z")

</div>

Something like this maybe?

```auto
const entity = args.currentEntities[0];

const linkedEntities = await fibery.getEntityById(entity.type, entity.id, ['Box', 'linked Material'];

const linkedBoxes = linkedEntities['Box'].map(({ id }) => id);
[...]

```

See [this article](https://the.fibery.io/@public/User_Guide/Guide/Scripts-54/anchor=Example--750c74b5-7d59-4cff-bf1e-201d2e399de4) for a better example (if I understood your context properly).

---

<div class="post-metadata">

**Author:** ![Matt\_Blais](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/matt_blais/32/1464_2.png) [@Matt\_Blais](https://community.fibery.io/u/Matt_Blais)\
**Post date:** [April 25, 2023, 7:36pm UTC](https://community.fibery.io/t/use-automation-step-results-in-automation-scripting/4364/3 "2023-04-25T19:36:21Z")

</div>

This may or may not work, as it seems to be indeterminate whether previous steps have truly been “completed” when subsequent steps are run:

> [@What am I doing wrong?](https://community.fibery.io/t/what-am-i-doing-wrong/3080/4):
>
> Apparently it’s worse than that… It appears that additionally, the results of “very recently run” Rules (i.e., those triggered “at the same time”) are also unavailable slightly_frowning_face This is making it very difficult to do the following via no-code: Create a Button for the “Page” DB that creates and links five “Task” entities. Use a “Task” Rule to set the Start Date of each newly-created Task to the “most recently created Task’s” Due Date, plus 7 days (that bit is always empty). I’…

---

<div class="post-metadata">

**Author:** ![Tommy\_Hedley](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/tommy_hedley/32/6468_2.png) [@Tommy\_Hedley](https://community.fibery.io/u/Tommy_Hedley)\
**Post date:** [April 26, 2023, 1:58pm UTC](https://community.fibery.io/t/use-automation-step-results-in-automation-scripting/4364/4 "2023-04-26T13:58:22Z")

</div>

Thanks all! I will try these suggestions and update.

---

<div class="post-metadata">

**Author:** ![Chr1sG](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/chr1sg/32/3941_2.png) [@Chr1sG](https://community.fibery.io/u/Chr1sG)\
**Post date:** [April 26, 2023, 5:26pm UTC](https://community.fibery.io/t/use-automation-step-results-in-automation-scripting/4364/5 "2023-04-26T17:26:11Z")

</div>

> [@CHANGELOG: March 23 / Many-to-many relations in Lists and Smart Folders, Open Entities in panel from Board & Table View](https://community.fibery.io/t/changelog-march-23-many-to-many-relations-in-lists-and-smart-folders-open-entities-in-panel-from-board-table-view/2655):
>
> Support of many-to-many relations in Lists and Smart Folders Dozens of users asked us to add many-to-many relations support in Smart Folders and Lists, and we’ve implemented it now. You can create Hierarchical List and select entities linked by many-to-many relations. For example, we have Use Cases with many Features inside, but the same Feature can belong to many Use Cases. Here is the list that visualizes Use Cases and Features: Smart Folders can be c…

 ![image](https://us1.discourse-cdn.com/flex020/uploads/fibery/original/2X/c/cff4dc4ddb32296066f22824282bdcb93aa1d425.png)

---

<div class="post-metadata">

**Author:** ![Tommy\_Hedley](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/tommy_hedley/32/6468_2.png) [@Tommy\_Hedley](https://community.fibery.io/u/Tommy_Hedley)\
**Post date:** [April 27, 2023, 5:46pm UTC](https://community.fibery.io/t/use-automation-step-results-in-automation-scripting/4364/6 "2023-04-27T17:46:23Z")

</div>

@Chr1sG Thanks for the info! I’m still not sure that I’m able to get the correct entity info from the first step. When I log args.steps[1] it only returns the entity that the automation has triggered for, not the linked entity. Apologies if I’m just totally messing up the syntax.

 ![Automation Steps](https://us1.discourse-cdn.com/flex020/uploads/fibery/original/2X/4/4929f33987b13c1646b909c0c5597f63ab56c012.png)

 ![Automation Steps Results](https://us1.discourse-cdn.com/flex020/uploads/fibery/original/2X/0/00de45dbcef96e3014b44fcfae2bf7669d9ac97d.png)

---

<div class="post-metadata">

**Author:** ![Chr1sG](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/chr1sg/32/3941_2.png) [@Chr1sG](https://community.fibery.io/u/Chr1sG)\
**Post date:** [April 27, 2023, 6:13pm UTC](https://community.fibery.io/t/use-automation-step-results-in-automation-scripting/4364/7 "2023-04-27T18:13:38Z")

</div>

You’re not messing anything up. The steps[1] argument does indeed only return the triggering entity and not the entity that was linked. Sorry.

---

<div class="post-metadata">

**Author:** ![Tommy\_Hedley](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/tommy_hedley/32/6468_2.png) [@Tommy\_Hedley](https://community.fibery.io/u/Tommy_Hedley)\
**Post date:** [April 27, 2023, 9:45pm UTC](https://community.fibery.io/t/use-automation-step-results-in-automation-scripting/4364/8 "2023-04-27T21:45:28Z")

</div>

Alright, after quite a bit of messing around I think I found an ok way to do this. It seems like grabbing the first item in the array when sorting by modification date should always get you the most recently linked entity and therefore the entity that triggered the automation. I would be curious if there is a better way to do this, but this works ok for my purposes. As usual I **SUPER** appreciate everyone’s help!

```auto
const fibery = context.getService('fibery')
//Insert the name of your space below
const SPACE_NAME = ''
const entity = args.currentEntities[0]
//Modify the query for you scenario, the database I'm querying from is called 'Box' and the linked database is 'Material'
const query = `{findBoxes(id: {is: "${entity.id}"}) {materials(orderBy: {modificationDate: DESC}) {id, name, modificationDate}}}`
const result = await fibery.graphql(SPACE_NAME, query)
const firstMaterialId = result.data.findBoxes[0].materials[0].id;
console.log(firstMaterialId);
console.log(result)

```

---

<div class="post-metadata">

**Author:** ![helloitse](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/helloitse/32/498_2.png) [@helloitse](https://community.fibery.io/u/helloitse)\
**Post date:** [January 25, 2025, 7:03pm UTC](https://community.fibery.io/t/use-automation-step-results-in-automation-scripting/4364/10 "2025-01-25T19:03:30Z")

</div>

Thanks for posting this solution! I am in a similar boat today and wanting to make an edit to a task, when that task is linked to a Milestone that matches specific criteria.

The current automations editor doesn’t allow me to filter by Milestone criteria when creating an automation from the Tasks database. I can filter when creating an automation from the Milestones database, but can’t get the task that was linked (that caused the automation) in a script action, only with formulas.

@ChrisG can we turn [this reply](https://community.fibery.io/t/use-automation-step-results-in-automation-scripting/4364/6) into a feature request? The added scripting here takes things from no code to yes code and I think this is a great improvement!

---

<div class="post-metadata">

**Author:** ![Chr1sG](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/chr1sg/32/3941_2.png) [@Chr1sG](https://community.fibery.io/u/Chr1sG)\
**Post date:** [January 27, 2025, 2:00pm UTC](https://community.fibery.io/t/use-automation-step-results-in-automation-scripting/4364/11 "2025-01-27T14:00:55Z")

</div>

> [@helloitse](#):
>
> Thanks for posting this solution! I am in a similar boat today and wanting to make an edit to a task, when that task is linked to a Milestone that matches specific criteria.
> 
> The current automations editor doesn’t allow me to filter by Milestone criteria when creating an automation from the Tasks database.

In the example you describe, I would imagine that the easiest workaround is a formula (in the Task db) that applies the Milestone criteria, and thus is updated when a qualifying Milestone is linked.  
As it happens, we are shortly [about to release a feature](https://the.fibery.io/@public/Public_Roadmap/Roadmap-Board-5974#Roadmap_Item/Filter-and-color-code-by-a-related-Entity's-Fields-362) that will allow you to apply a filter based on a related entity’s fields, at which point the workaround will no longer be needed.

---

<div class="post-metadata">

**Author:** ![gb\_carbone](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/gb_carbone/32/5345_2.png) [@gb\_carbone](https://community.fibery.io/u/gb_carbone)\
**Post date:** [March 5, 2025, 7:09pm UTC](https://community.fibery.io/t/use-automation-step-results-in-automation-scripting/4364/12 "2025-03-05T19:09:56Z")

</div>

I am hoping so hard that Fibery will invest more time and effort in the automations & rules product area. I think it might be one of if not the biggest weakness of Fibery given the importance it has in this type of product.

We’ve been building automations and back-end logic in low code and no code platforms for multiple years in multiple platforms (Xano, Pipedream, Airtable, Zapier…) but we still can’t figure out the way to create automations efficiently in Fibery.

The fact of the matter is we pretty much always end up trying to fit everything in a script because the no code components are very limited. But then the Fibery Script API is so complex for what is needed, there’s always a little something that breaks the whole thing and ultimately we’re forced to move onto something else.

We had hopes with Fibery AI, but even it cannot figure out the most basic things. Other coding LLMs can’t either.

Can someone from the Fibery team inject some hope here?? 🙂

---

<div class="post-metadata">

**Author:** ![gb\_carbone](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/gb_carbone/32/5345_2.png) [@gb\_carbone](https://community.fibery.io/u/gb_carbone)\
**Post date:** [March 5, 2025, 7:14pm UTC](https://community.fibery.io/t/use-automation-step-results-in-automation-scripting/4364/13 "2025-03-05T19:14:22Z")

</div>

Oh god, I just found [this thread](https://community.fibery.io/t/feedback-needed-scripts-in-automations-that-shouldnt-be-scripts/6560/64). That might have provided me with the hope I needed.

---

<div class="post-metadata">

**Author:** ![derbenoo](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/derbenoo/32/11540_2.png) [@derbenoo](https://community.fibery.io/u/derbenoo)\
**Post date:** [March 6, 2025, 12:37pm UTC](https://community.fibery.io/t/use-automation-step-results-in-automation-scripting/4364/14 "2025-03-06T12:37:01Z")

</div>

> I am hoping so hard that Fibery will invest more time and effort in the automations & rules product area. I think it might be one of if not the biggest weakness of Fibery given the importance it has in this type of product.

@gb_carbone I was feeling exactly the same way, Fibery automation rules are very powerful but somewhat inaccessible to users that do not know how to code or use the Fibery API. So I decided to build an integration for Fibery called [Fiberflow](https://fiberflow.io), which addresses these issues by providing a no-code editor for building advanced automations. For example, there is already an action for conditional logic (if-then-else), which helps quite a bit building automations. You can check out [a simple automation using the conditional action](https://fiberflow.fiberflow.io/@public/Templates/Ticket/4913a27e-81ae-4748-a136-0e54fcd4f6b9), the [Public Roadmap](https://fiberflow.fibery.io/@public/Product/Roadmap-47) or submit suggestions for upcoming features 🙂

---

<div class="post-metadata">

**Author:** ![Matt\_Blais](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/matt_blais/32/1464_2.png) [@Matt\_Blais](https://community.fibery.io/u/Matt_Blais)\
**Post date:** [March 6, 2025, 6:27pm UTC](https://community.fibery.io/t/use-automation-step-results-in-automation-scripting/4364/15 "2025-03-06T18:27:07Z")

</div>

> [@derbenoo](#):
>
> You can check out [a simple automation using the conditional action](https://fiberflow-templates.fiberflow.io/@public/Ticket-tracker/Ticket/5d3dcc90-8b72-47bf-97ed-a4b6b926aa15)

I can’t see anything interesting at that link:

 ![image](https://us1.discourse-cdn.com/flex020/uploads/fibery/original/2X/d/d3e3849725dfa4ccd5844603f9f04ffa6c8b0af4.png)

---

<div class="post-metadata">

**Author:** ![derbenoo](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/derbenoo/32/11540_2.png) [@derbenoo](https://community.fibery.io/u/derbenoo)\
**Post date:** [March 6, 2025, 7:36pm UTC](https://community.fibery.io/t/use-automation-step-results-in-automation-scripting/4364/16 "2025-03-06T19:36:01Z")

</div>

@Matt_Blais unfortunate timing, I just deployed after a large refactor and broke a couple of things including the share functionality. Now It should work 🙂

> **[Fiberflow](https://fiberflow.fiberflow.io/@public/Templates/Ticket/4913a27e-81ae-4748-a136-0e54fcd4f6b9)**
