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.
@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.
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!
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)
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 into a feature request? The added scripting here takes things from no code to yes code and I think this is a great improvement!
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 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.
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??
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, 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, the Public Roadmap or submit suggestions for upcoming features
@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