Clear field value with a condition

I’ve created a button named “Deactivate” to deactivate someone from my team when this person leaves the project. This button do some updates of some fields:

There is this relation field called Tarefas (Tasks) that I wanted to be cleared but, with a condition. I wanted to clear only the Tarefas (Tasks) which the field Situação (Status) would not be Feita (Done) or Cancelada (Cancelled).

How can I make a formula with a condition to clear the field value. Is it possible?

Thanks

Try this

[Step 1 User].Tarefas.Filter([Step 1 User].Situação != "Feita" and [Step 1 User].Situação != "Cancelada")

In this case you are filtering the user, right? But Situação it’s a field of the Task. I wanted to filter the Task, not the user…

As in clear the value of all tasks that have a situation Feita or Cancelada connected to the user…

Maybe I misunderstood. Is Status a field property of the Task or the User? If it’s the Task, then you will need:

[Step 1 User].Tarefas.Filter(Situação.Name != "Feita" and Situação.Name != "Cancelada")

That assumes you want to keep the Tasks which are neither Done nor Cancelled.

If you want to keep the Tasks which are Done or Cancelled, it would be

[Step 1 User].Tarefas.Filter(Situação.Name = "Feita" or Situação.Name = "Cancelada")

Yes! That would be the case.

But I want to clear the field, that’s the action. So I would have to write it right?

Summing up: I want the automation to disconnect (clear the field) from the user all the tasks that, in that moment, don’t have a status field which are Done or Cancelled.

Something like:

CLEAR THE [Step 1 User].Tarefas IF [Step 1 User].Tarefas.Filter(Situação.Name != “Feita” and Situação.Name != “Cancelada”)…

Think of it like you don’t need to explicitly clear the field of the things you don’t want, but rather you overwrite (=update) the field to be the things you do want, based on the opposite filter (which in some cases might just give nothing).

So if you want to get rid of Tasks which are not Done and not Cancelled, that means you want to keep Tasks which are either Done or Cancelled, if there are any.

i.e. you update the field with

[Step 1 User].Tarefas.Filter(Situação.Name = "Feita" or Situação.Name = "Cancelada")

Perfect!

It makes sense!

Thank you very much!