Trigger type identity attribute, with filter two conditions

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 :

  1. Your filter uses “smart quotes” ( ‘ ’ ). Replace with normal quotes (’ or ").

  2. The && part can’t work as written because each element in changes[] has only one attribute. So @.attribute can’t be endDateForTransfer and transferinprogress 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 both endDateForTransfer and transferinprogress are present in the same event’s changes[].

Hi @guilherme_sec

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))]

Thanks

Thank you Noor, this is working fine for me