How to use Directus flows to copy a value from one column to another on creation

Viewed 671

In directus I am creating records where one column is a float that contains negative numbers.

On creation of a record I would like to copy the absolute value of this column to another column in the same collection automatically.

Example: After creating a record with a column having this: -45.20 value, I would like to create an automatic flow that copies 45.20 part of the cell to another column in that same record just inserted.

Is this possible with flows in directus?

1 Answers

In general terms, it sounds like you are looking to read data the moment it is created, transform it, then write it back in to another Field/Collection. This is my understanding of how to do this:

For the first and last steps, you can use the Event Hook Trigger as well as the Read/Update Items Operations.

However, the second step requires you write a function to transform the value. At the time of writing this answer, there is no Operation to write/apply a function in the Flow. Therefore, in order to have function logic, you can create your own Custom Hook to add that logic or use a Webhook Operation to send the data off to another service, process/transform it as desired, then return it- either to another Flow via a Webhook Trigger, or just writing the new Item directly into the database.

Related