[Workflow] Filter for attribute change only if two specific attributes are changing

Hello,

We would like to create a specific workflow so that we can create a certification campaign if the user is changing of manager & team. We are struggling finding an Xpath for this. We have manage to detect when there is a change of both attributes, but we are not able to exclude a change of manager only.

Example :
User 1 has a new manager, but team is not changing → we do not want to execute the workflow
User 2 has a new team → we want to execute the workflow
User 3 has a new team and a new manager → we want to execute the workflow

Thanks for your help

1 Like

Hi @alexandre_mazars,

I am assuming you are using trigger as “Identity Attribute Changed”. You could choose to just filter it on team attribute like this $.changes[?(@.attribute == "team")]

If you want to trigger on the workflow when both attribute changes, you could try $.changes[?(@.attribute == "team" && @.attribute == "manager")]

1 Like

Hello Animesh,

Using Online JSONPath Evaluator Tool (javainuse.com), with the following JSON and your filter I’m not able to obtain any result :

{
    "identity":{
        "id":"ee769173319b41d19ccec6cea52f237b",
        "name":"john.doe",
        "type":"IDENTITY"
    },
    "changes":[
        {
            "attribute":"department",
            "oldValue":"sales",
            "newValue":"marketing"
        },
        {
            "attribute":"manager",
            "oldValue":{
                "id":"ee769173319b41d19ccec6c235423237b",
                "name":"william.wilson",
                "type":"IDENTITY"
            },
            "newValue":{
                "id":"ee769173319b41d19ccec6c235423236c",
                "name":"ed.engineer",
                "type":"IDENTITY"
            }
        },
        {
            "attribute":"email",
            "oldValue":"[email protected]",
            "newValue":"[email protected]"
        }
    ]
}

Hi Alexandre,

Try the filter below. I checked with the above JSON and it is working. I hope it solves the issue with your scenario.

$[?(("department" in @.changes[*].attribute && "manager" in @.changes[*].attribute))]
2 Likes

Hello,

You’re right ! We can also use :

$[?($.changes[?(@.attribute == "department")] size 1)][?($.changes[?(@.attribute == "manager")] size 1)]

Thanks for your help !

1 Like

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.