Hi everyone, I’m trying to create a filter that activates when the cost center is changed OR when two other fields are changed.
In the case of the cost center, the workflow activates automatically; otherwise, the workflow activates when the other two fields are changed.
This my filter but it’s not working
$.changes[?(@.attribute == ‘costCenter’ || (@.attribute == ‘endDateForTransfer’ && @.attribute == ‘transferinprogress’))]
Hi @guilherme_sec — two issue need need to be addressed here :
Your filter uses “smart quotes” ( ‘ ’ ). Replace with normal quotes (’ or ").
The && part can’t work as written because each element in changes[] has only one attribute. So @.attribute can’t be endDateForTransferandtransferinprogress in the same array item.
Use a filter that checks whether the attributes exist anywhere in the changes array:
$[?(
("costCenter" in @.changes[*].attribute) ||
(("endDateForTransfer" in @.changes[*].attribute) && ("transferinprogress" in @.changes[*].attribute))
)]
That will trigger when costCenter changes OR when bothendDateForTransfer and transferinprogress are present in the same event’s changes[].
Try this filter in the trigger and this should definitely work as I have a similar filter setup and is working fine for a workflow (movers access review).
$[?((“endDateForTransfer” in @.changes[*].attribute && “transferinprogress” in @.changes[*].attribute) || (“costCenter” in @.changes[*].attribute))]