Json expression not working in compare string

Hello! I am using a workflow with a Provisioning Completed trigger, and I am trying to filter on the operation to create different workflows for ‘Add’ vs. ‘Remove’. I’m having some difficulty getting the json filter working and I could use some help.

Looking at the test input to the workflow:

{
  "trackingNumber": "4b4d982dddff4267ab12f0f1e72b5a6d",
  "action": "IdentityRefresh",
  "requester": {
    "id": "2c91808b6ef1d43e016efba0ce470906",
    "name": "Adam Admin",
    "type": "IDENTITY"
  },
  "recipient": {
    "id": "2c91808b6ef1d43e016efba0ce470909",
    "name": "Ed Engineer",
    "type": "IDENTITY"
  },
  "errors": [
    "General Error",
    "Connector AD Failed"
  ],
  "warnings": [
    "Notification Skipped due to invalid email"
  ],
  "sources": "Corp AD, Corp LDAP, Corp Salesforce",
  "accountRequests": [
    {
      "source": {
        "id": "4e4d982dddff4267ab12f0f1e72b5a6d",
        "name": "Corporate Active Directory",
        "type": "SOURCE"
      },
      "accountId": "CN=Rob.Robertson,ou=csm,ou=sales,dc=helpco,dc=com",
      "accountOperation": "Modify",
      "provisioningResult": "SUCCESS",
      "provisioningTarget": "Corp AD",
      "ticketId": "72619262",
      "attributeRequests": [
        {
          "operation": "Add",
          "attributeName": "memberOf",
          "attributeValue": "CN=sales,DC=helpco,DC=com"
        }
      ]
    }
  ]
}

The filter I am trying to use is:

$.trigger.accountRequests[?(@.source.name == "Corporate Active Directory")].attributeRequests[?(@.attributeValue == "CN=sales,DC=helpco,DC=com")].operation

In a “String Compare” card to determine if the operation is add or remove. If I replace the second conditional (attributeValue) with “0”, it works fine, but the conditional does not work. I tried it in a JSON validator online and it works fine. Is there some SailPoint restriction on the number of conditional filters you can have in a JSON expression?

I’m guessing you’re hit with this little bit of quirkiness with the Trigger vs Workflow evaluation difference:

Notice that it doesn’t evaluate to just: [“Add”], but instead, it resulted in [[“Add”]]. (I’ve removed .trigger from the JSON Path, but that’s not important / the main point)

On that page, using the same JSON Path and JSON, if you change the implementation (the drop down) from Workflow to Event Trigger, that comes back with [“Add”]:

Interesting. Well, given I’m trying to use this in a Workflow, is this a bug then? I suppose I should open a support request? I don’t know how to work around it other than assuming there will only ever be one attribute request, which seems like a bad assumption

The filter you are trying to use, returns a list [“Add”] and you 're trying to compare it with a string.
Try to add the index [0] to the filter, and see if it works!

Hi @jimjohnson because the JSONPath is returning an Array with the list of values something like:

[
"Add"
]

And i wasn’t able to find something that will transform this into a string directly something like operation[0] or operation[1], but i did found something on sailpoint workflow side that you can do.

Add a loop operation ->  this will be able to iterate over the result that is coming as an array

Inside loop -> Add Compare string as shown in image below

This should do the job. Letme know if this helps :slight_smile:

Thanks Neeraj! I appreciate the detailed response, but that’s a bit more complexity than I’m wanting for this simple use case, and we’ve seen some issues troubleshooting loops on workflows in the past, so we try to avoid them.

I opened a support ticket to see if I can get a proper solution. I’ll follow up here when I hear back.

This is true. Workflows are bit challenging and that too when it comes to looping.

That would be great.